import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.MenuBar;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.Spinner;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

public class ComboBoxQuit extends Application {
        private static Stage stage;

        @Override
        public void start(Stage primaryStage) {
            stage = primaryStage;

            Label label = new Label("Use Cmd+W to toggle");
            CheckBox checkBox = new CheckBox("Debug toggle");
            checkBox.setDisable(true);
            VBox feedback = new VBox(label, checkBox);
            feedback.setSpacing(10);

            Menu menu = new Menu("Test");
            MenuItem wMenuItem = new MenuItem("Toggle CheckBox");
            wMenuItem.setOnAction(e -> {
                checkBox.setSelected(!checkBox.isSelected());
            });
            wMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN));
            menu.getItems().add(wMenuItem);

            MenuBar menuBar = new MenuBar(menu);
            menuBar.setUseSystemMenuBar(true);
            BorderPane borderPane = new BorderPane();
            borderPane.setPadding(new Insets(10, 10, 10, 10));
            borderPane.setTop(menuBar);
            borderPane.setCenter(createControls());
            borderPane.setBottom(feedback);

            Scene mainScene = new Scene(borderPane, 200, 200);
            primaryStage.setScene(mainScene);
            primaryStage.show();
        }

        public VBox createControls() {
            TextField textField = new TextField();
            textField.setEditable(true);
            ObservableList<String> list = FXCollections.observableArrayList();
            list.addAll("word", "sentence", "paragraph");
            ComboBox<String> comboBox = new ComboBox<>(list);
            comboBox.setEditable(true);
            DatePicker datePicker = new DatePicker();
            Spinner spinner = new Spinner<Integer>(0, 100, 5);
            spinner.setEditable(true);
            VBox vbox = new VBox(textField, comboBox, datePicker, spinner);
            return vbox;
        }
}

