public class DisplayClock extends Application
1:
2: import javafx.application.Application;
3: import javafx.geometry.Pos;
4: import javafx.stage.Stage;
5: import javafx.scene.Scene;
6: import javafx.scene.control.Label;
7: import javafx.scene.layout.BorderPane;
8:
9: public class DisplayClock extends Application {
10: @Override // Override the start method in the Application class
11: public void start(Stage primaryStage) {
12: // Create a clock and a label
13: ClockPane clock = new ClockPane();
14: String timeString = clock.getHour() + ":" + clock.getMinute()
15: + ":" + clock.getSecond();
16: Label lblCurrentTime = new Label(timeString);
17:
18: // Place clock and label in border pane
19: BorderPane pane = new BorderPane();
20: pane.setCenter(clock);
21: pane.setBottom(lblCurrentTime);
22: BorderPane.setAlignment(lblCurrentTime, Pos.TOP_CENTER);
23:
24: // Create a scene and place it in the stage
25: Scene scene = new Scene(pane, 250, 250);
26: primaryStage.setTitle("DisplayClock"); // Set the stage title
27: primaryStage.setScene(scene); // Place the scene in the stage
28: primaryStage.show(); // Display the stage
29: }
30:
31: /**
32: * The main method is only needed for the IDE with limited
33: * JavaFX support. Not needed for running from the command line.
34: */
35: public static void main(String[] args) {
36: launch(args);
37: }
38: }