有没有大神帮忙解释一下这段
/** * 界面逻辑控制器, */@SuppressWarnings(“unused”)
public class FXMLDocumentController implements Initializable {
private Stage stage;
private File fileOpened;
@FXML
private TextArea textArea;
@Override
public void initialize(URL url, ResourceBundle rb) { }
void setStage(Stage stage) {
this.stage = stage;
openFile(null);
}
private void openFile(File file) {
fileOpened = file;
if (fileOpened == null) {
stage.setTitle("记事本");
} else { stage.setTitle(fileOpened.getAbsolutePath());
}
} private void readFile(File file) {
if (file == null) {
textArea.setText("");
return;
}
try {
textArea.setText(new String(Files.readAllBytes(Paths.get(file.getAbsolutePath())))); } catch (IOException e) {
Alert alert = new Alert(Alert.AlertType.ERROR); alert.setContentText("file open error: " + e.getMessage()); alert.show();
}
}
private void saveFileAs(File file) { try { Files.write(Paths.get(file.getAbsolutePath()), textArea.getText().getBytes());
} catch (IOException e) {
Alert alert = new Alert(Alert.AlertType.ERROR); alert.setContentText(“file write error: " + e.getMessage());
alert.show();
}
openFile(file); }
/** * 功能未实现时调用
* @param event
* */ @FXML
* private void onNotImplementedItemClick(ActionEvent event) { Alert alert = new Alert(Alert.AlertType.ERROR); String text = ((MenuItem) event.getTarget()).getText(); alert.setContentText(text + " not implemented”); alert.show();
}