Java Reference
In-Depth Information
public ObservableList choiceBoxItems = FXCollections.observableArrayList(
"Choice A",
"Choice B",
"Choice C",
"Choice D"
);
public double maxRpm = 8000.0;
public DoubleProperty rpm = new SimpleDoubleProperty(0);
public double maxKph = 300.0;
public DoubleProperty kph = new SimpleDoubleProperty(0);
}
We refer to snippets from this listing as they apply to relevant UI controls that we walk through in the main Java
file of the StarterApp program. This file is named StarterAppMain.java and is shown in its entirety one chunk at a
time during our discussion of the JavaFX UI controls.
Setting the stage for the StarterApp program, Listing 6-2 shows the first portion of the StarterAppMain.java file,
in which the Stage and Scene are received and created. In addition, the root of the Scene is assigned a BorderPane ,
which provides the UI structure in which the MenuBar , ToolBar , and TabPane will reside.
Listing 6-2. The First Portion of StarterAppMain.java
package projavafx.starterapp.ui;
... imports omitted...
public class StarterAppMain extends Application {
StarterAppModel model = new StarterAppModel();
Stage stage;
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(final Stage primaryStage) {
stage = primaryStage;
VBox topBox = new VBox(createMenus(), createToolBar());
BorderPane borderPane = new BorderPane();
borderPane.setCenter(createTabs());
borderPane.setTop(topBox);
Scene scene = new Scene(borderPane, 980, 600);
scene.getStylesheets().add("/projavafx/starterapp/ui/starterApp.css");
stage.setScene(scene);
stage.setTitle("Starter App");
stage.show();
}
Search WWH ::




Custom Search