Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javafxExamples;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Optional;
- import javafx.application.Application;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.ChoiceDialog;
- import javafx.scene.control.ComboBox;
- import javafx.scene.layout.BorderPane;
- import javafx.stage.Stage;
- public class ComboErrorTest extends Application {
- String[] list={"Jamie", "Arthur", "Gordon"};
- private Stage stage;
- public static void main(String[] args) {
- launch(args);
- }
- @Override
- public void start(Stage stage) throws Exception {
- //create box in main stage.
- ComboBox<String> comboBox=new ComboBox<String>();
- for (int i=0; i<list.length; i++){
- comboBox.getItems().add(list[i]);
- }
- comboBox.getSelectionModel().select(list[0]);
- BorderPane pane = new BorderPane(comboBox);
- pane.setPrefSize(400, 250);
- //dialog bit
- List<String> choices = new ArrayList<>();
- choices.add("a");
- choices.add("b");
- choices.add("c");
- ChoiceDialog<String> dialog = new ChoiceDialog<>("b", choices);
- dialog.setTitle("Choice Dialog");
- dialog.setHeaderText("Look, a Choice Dialog");
- dialog.setContentText("Choose your letter:");
- Button dialogButton=new Button("Open Dialog...");
- dialogButton.setOnAction((action)->{
- // Traditional way to get the response value.
- Optional<String> result = dialog.showAndWait();
- if (result.isPresent()){
- System.out.println("Your choice: " + result.get());
- }
- });
- pane.setBottom(dialogButton);
- Scene scene = new Scene(pane);
- stage.setTitle("ComboError Demo");
- stage.setScene(scene);
- stage.show();
- }
- }
- java -Dglass.accessible.force=false ...
- System.setProperty("glass.accessible.force", "false");
- comboBox.setOnMousePressed(new EventHandler<MouseEvent>(){
- @Override
- public void handle(MouseEvent event) {
- comboBox.requestFocus();
- }
- });
- System.setProperty("glass.accessible.force", "false");
- Pen 'n touch Wacom bamboo create tablet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement