I have an old swing Jcombobox which i used to use like this.
baudRatecomboBox = new JComboBox(baudRates);
baudRatecomboBox.setSelectedIndex(1);
GridBagConstraints gbc_baudRateComboBox = new GridBagConstraints();
gbc_baudRateComboBox.fill = GridBagConstraints.HORIZONTAL;
gbc_baudRateComboBox.insets = new Insets(0, 0, 5, 5);
gbc_baudRateComboBox.gridx = 1;
gbc_baudRateComboBox.gridy = 3;
getContentPane().add(baudRatecomboBox, gbc_baudRateComboBox);
String[] baudRates = { "2400", "4800", "9600", "14400", "19200", "38400", "56000", "115200" };
I am re-writing my application using JavaFX and i cant get the comboBox to populate.
This is my FXML
<ComboBox id="baudRatecomboBox" fx:id="baudRateComboBox" prefHeight="30.0" prefWidth="87.0" promptText="Baud" />
and this is my Java
@FXML
ComboBox baudRateComboBox;
public void start(Stage primaryStage) {
try {
Parent root = FXMLLoader.load(getClass().getResource("LaserControllerUI.fxml"));
Scene scene = new Scene(root);
primaryStage.setTitle("Laser Controller");
primaryStage.setScene(scene);
primaryStage.show();
scene.getStylesheets().add
(LaserControllerUI.class.getResource("LaserControllerUI.css").toExternalForm());
ComboBox<String> baudRateComboBox = new ComboBox();
baudRateComboBox.getItems().addAll(baudRates);
baudRateComboBox.setVisible(true);
Why isnt my ComboBox populating?