import java.net.URL; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.CheckBox; import javafx.scene.control.MenuBar; import javafx.stage.Stage; public class AcceleratorTest extends Application { @FXML MenuBar menuBar; @FXML CheckBox useSystemMenuBarCheckBox; public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage primaryStage) throws Exception { final FXMLLoader loader = new FXMLLoader(); final URL fxmlURL = getClass().getResource("AcceleratorTest.fxml"); assert fxmlURL != null; loader.setLocation(fxmlURL); loader.setController(this); final Parent root = loader.load(); assert root != null; assert menuBar != null; assert useSystemMenuBarCheckBox != null; primaryStage.setScene(new Scene(root)); primaryStage.sizeToScene(); primaryStage.show(); } @FXML private void handleCommand1(ActionEvent e) { System.out.println("Command 1"); } @FXML private void handleCommand2(ActionEvent e) { System.out.println("Command 2"); } @FXML private void handleUseSystemMenuBar(ActionEvent e) { menuBar.setUseSystemMenuBar(useSystemMenuBarCheckBox.isSelected()); System.out.println("menuBar.isUseSystemMenuBar: " + menuBar.isUseSystemMenuBar()); } }