List of usage examples for javafx.scene.control ComboBox ComboBox
public ComboBox()
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); ComboBox<String> myComboBox = new ComboBox<String>(); myComboBox.getItems().addAll("A", "B", "C", "D", "E"); myComboBox.setEditable(true);/*from w w w . j a v a 2 s. c om*/ myComboBox.setPromptText("Email address"); Group root = (Group) scene.getRoot(); root.getChildren().add(myComboBox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); ComboBox<String> myComboBox = new ComboBox<String>(); myComboBox.getItems().addAll("A", "B", "C", "D", "E"); myComboBox.setValue("A"); System.out.println(myComboBox.getValue()); Group root = (Group) scene.getRoot(); root.getChildren().add(myComboBox);//from www . j av a2 s . c o m stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); ComboBox<String> myComboBox = new ComboBox<String>(); myComboBox.getItems().addAll("A", "B", "C", "D", "E"); myComboBox.setEditable(true);//from ww w . j av a 2 s . c o m Group root = (Group) scene.getRoot(); root.getChildren().add(myComboBox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); ComboBox<String> myComboBox = new ComboBox<String>(); myComboBox.getItems().addAll("A", "B", "C", "D", "E"); myComboBox.setValue("A"); System.out.println(myComboBox.getValue()); myComboBox.setValue(null);//from ww w . ja va 2s .c o m Group root = (Group) scene.getRoot(); root.getChildren().add(myComboBox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); ComboBox<String> emailComboBox = new ComboBox<String>(); emailComboBox.getItems().addAll("A", "B", "C", "D", "E"); emailComboBox.setValue("A"); System.out.println(emailComboBox.getValue()); GridPane grid = new GridPane(); grid.setVgap(4);/*from w w w .j a v a2s . co m*/ grid.setHgap(10); grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("To: "), 0, 0); grid.add(emailComboBox, 1, 0); Group root = (Group) scene.getRoot(); root.getChildren().add(grid); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 200, 200); ComboBox<String> myComboBox = new ComboBox<String>(); myComboBox.getItems().addAll("A", "B", "C", "D", "E"); myComboBox.setCellFactory(new Callback<ListView<String>, ListCell<String>>() { @Override//from w w w . ja v a 2 s. c o m public ListCell<String> call(ListView<String> param) { final ListCell<String> cell = new ListCell<String>() { { super.setPrefWidth(100); } @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (item != null) { setText(item); if (item.contains("A")) { setTextFill(Color.RED); } else if (item.contains("B")) { setTextFill(Color.GREEN); } else { setTextFill(Color.BLACK); } } else { setText(null); } } }; return cell; } }); Group root = (Group) scene.getRoot(); root.getChildren().add(myComboBox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(final Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 400, 300, Color.WHITE); GridPane gridpane = new GridPane(); ComboBox<Rectangle> cmb = new ComboBox<Rectangle>(); cmb.getItems().addAll(new Rectangle(10, 10, Color.RED), new Rectangle(10, 10, Color.GREEN), new Rectangle(10, 10, Color.BLUE)); gridpane.add(cmb, 2, 0);//from w ww. j a va 2 s . c o m root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4"); ComboBox<String> emailComboBox = new ComboBox<String>(); emailComboBox.setItems(list);// w w w.ja va 2s . c o m emailComboBox.setValue("A"); GridPane grid = new GridPane(); grid.setVgap(4); grid.setHgap(10); grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("To: "), 0, 0); grid.add(emailComboBox, 1, 0); Group root = (Group) scene.getRoot(); root.getChildren().add(grid); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4"); ComboBox<String> emailComboBox = new ComboBox<String>(); emailComboBox.setItems(list);/* www. ja v a2 s . c om*/ emailComboBox.setValue("A"); System.out.println(emailComboBox.visibleRowCountProperty()); GridPane grid = new GridPane(); grid.setVgap(4); grid.setHgap(10); grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("To: "), 0, 0); grid.add(emailComboBox, 1, 0); Group root = (Group) scene.getRoot(); root.getChildren().add(grid); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4"); ComboBox<String> emailComboBox = new ComboBox<String>(); emailComboBox.setItems(list);// w w w .ja va 2 s.com emailComboBox.setValue("A"); StringConverter sc = new ShortStringConverter(); emailComboBox.setConverter(sc); GridPane grid = new GridPane(); grid.setVgap(4); grid.setHgap(10); grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("To: "), 0, 0); grid.add(emailComboBox, 1, 0); Group root = (Group) scene.getRoot(); root.getChildren().add(grid); stage.setScene(scene); stage.show(); }