0

I have combo box and need create a frame to it. How I can add the frame below?

comboBox frame

ComboBox<String> combobox = new ComboBox<String>();
ObservableList<String> items = FXCollections.observableArrayList("RED", "BLUE", "GREEN", "YELLOW", "BLACK");
combobox.setItems(items);
combobox.setTranslateX(250);
combobox.setTranslateY(300);
combobox.setPromptText("Circle Color");

1 Answers1

0
public class Main extends Application {
public static void main(String[] args) {
   Application.launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("BorderPane Test");

//Creating StackPane
StackPane sp = new StackPane();

// add Combobox to scene
ComboBox<String> combobox = new ComboBox<String>();
ObservableList<String> items = FXCollections.observableArrayList("RED", "BLUE",     "GREEN", "YELLOW", "BLACK");
combobox.setItems(items);
combobox.setTranslateX(250);
combobox.setTranslateY(300);
combobox.setPromptText("Circle Color");
sp.getChildren().add(btn);

//Adding StackPane to the scene
Scene scene = new Scene(sp,300,200);
primaryStage.setScene(scene);
primaryStage.show();
}
}

Set the style of the combo box in an external CSS file. There are many tutorials on the Internet how to do that. For example, look here. Or even simpler without an extra file here.

Jakob Herk
  • 157
  • 11