-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPushMe.java
More file actions
56 lines (44 loc) · 1.75 KB
/
PushMe.java
File metadata and controls
56 lines (44 loc) · 1.75 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
46
47
48
49
50
51
52
53
54
55
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class PushMe extends Application
{
@Override
public void start(Stage stage)
{
// create and configure a text field for user entry
TextField pushMeTextField = new TextField();
pushMeTextField.setMaxWidth(250);
// create and configure a label to display the output
Label pushMeLabel= new Label();
pushMeLabel.setTextFill(Color.RED);
pushMeLabel.setFont(Font.font("Arial", 20));
// create and configure a label which will cause the text to be displayed
Button pushMeButton = new Button();
pushMeButton.setText("Type something in the box then push me");
pushMeButton.setOnAction(e -> pushMeLabel.setText("You entered: " + pushMeTextField.getText()));
// create and configure a VBox to hold our components
VBox root = new VBox();
root.setSpacing(10);
root.setAlignment(Pos.CENTER);
//add the components to the VBox
root.getChildren().addAll(pushMeTextField, pushMeButton, pushMeLabel);
// create a new scene
Scene scene = new Scene(root, 350, 150);
//add the scene to the stage, then configure the stage and make it visible
stage.setScene(scene);
stage.setTitle("Push Me");
stage.show();
}
public static void main(String[] args)
{
launch(args);
}
}