-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonDemo.java
More file actions
45 lines (35 loc) · 1.17 KB
/
ButtonDemo.java
File metadata and controls
45 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.control.Label;
import javafx.scene.control.Button;
import javafx.geometry.Pos;
/** * A Button Demo */
public class ButtonDemo extends Application
{
public static void main(String[] args)
{
// Launch the application.
launch(args);
} @Override
public void start(Stage primaryStage)
{
// Create a Label control.
Label myLabel = new Label("Click the button to see a message.");
// Create a Button control.
Button myButton = new Button("Click Me");
// Put the Label and Button in a VBox with 10 pixels of spacing.
VBox vbox = new VBox(10, myLabel, myButton);
// Create a Scene with the VBox as its root node.
Scene scene = new Scene(vbox, 300, 100);
// Set the scene's alignment to center.
vbox.setAlignment(Pos.CENTER);
// Add the Scene to the Stage.
primaryStage.setScene(scene);
// Set the stage title.
primaryStage.setTitle("Button Demo");
// Show the window.
primaryStage.show();
}
}