-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBtnExample.java
More file actions
37 lines (32 loc) · 1.16 KB
/
Copy pathBtnExample.java
File metadata and controls
37 lines (32 loc) · 1.16 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
package application;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.scene.layout.StackPane;
public class BtnExample extends Application{
@Override
public void start(Stage primaryStage) throws Exception {
// TODO Auto-generated method stub
Button btn1=new Button("Say, Hello World");
btn1.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
// TODO Auto-generated method stub
System.out.println("hello world");
}
});
StackPane root=new StackPane();
root.getChildren().add(btn1);
Scene scene=new Scene(root,600,400);
primaryStage.setTitle("First JavaFX Application");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main (String[] args)
{
launch(args);
}
}