/* * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. */ package controls; import com.sun.javafx.runtime.VersionInfo; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.scene.Scene; import javafx.scene.control.ChoiceBox; import javafx.scene.control.ComboBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; /** * * @author Sergey */ public class TestComboBox extends Application{ @Override public void start(Stage stage) throws Exception { VBox root = new VBox(5); Scene scene = new Scene(root, 300,300); stage.setScene(scene); String style = "-fx-padding: 10 5 30 15;"; ComboBox cb = new ComboBox(); cb.setItems(FXCollections.observableArrayList("combobox", "two", "three three")); cb.getSelectionModel().select(0); cb.setPrefWidth(100); cb.setStyle(style); ComboBox cbe = new ComboBox(); cbe.setItems(FXCollections.observableArrayList("combo editable", "two", "three three")); cbe.getSelectionModel().select(0); cbe.setPrefWidth(100); cbe.setEditable(true); cbe.setStyle(style); ChoiceBox cb2 = new ChoiceBox(); cb2.setItems(FXCollections.observableArrayList("choicebox", "two", "three three")); cb2.getSelectionModel().select(0); cb2.setPrefWidth(100); cb2.setStyle(style); root.getChildren().addAll(cb, cbe, cb2); stage.show(); stage.setTitle(VersionInfo.getRuntimeVersion()); } public static void main(String[] args) { launch(args); } }