-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavaFxtesting
61 lines (47 loc) · 1.55 KB
/
JavaFxtesting
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
56
57
58
59
60
61
package com.mycompany.nadiah;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Label;
import java.io.IOException;
import javafx.scene.control.Button;
import javafx.scene.layout.*;
public class App extends Application {
private static Scene scene;
@Override
public void start(Stage stage) throws IOException {
stage.setTitle("Testing button");
Button b = new Button("Button");
TilePane r = new Tilepane();
Label l = new Label();
EventHandler<ActionEvent> event = new EventHandler<ActionEvent>(){
public void handle (ActionEvent e){
l.setText("Hello!");
};
};
b.setOnAction(event);
r.getChildren().add(b);
r.getChildren().add(l);
scene = new Scene(loadFXML("primary"), 640, 480);
stage.setScene(scene);
stage.show();
}
static void setRoot(String fxml) throws IOException {
scene.setRoot(loadFXML(fxml));
}
private static Parent loadFXML(String fxml) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
return fxmlLoader.load();
}
public static void main(String[] args) {
launch(args);
}
private static class Tilepane extends TilePane {
public Tilepane() {
}
}
}