Skip to content

Commit eb5678b

Browse files
committed
FXML
1 parent 19b7643 commit eb5678b

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

JavaFX/031_fxml/Controller.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package sample;
2+
3+
import javafx.fxml.Initializable;
4+
import java.net.URL;
5+
import java.util.ResourceBundle;
6+
7+
public class Controller implements Initializable {
8+
9+
@Override
10+
public void initialize(URL location, ResourceBundle resources) {
11+
System.out.println("View is now loaded!");
12+
}
13+
14+
}

JavaFX/031_fxml/Main.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package sample;
2+
3+
import javafx.application.Application;
4+
import javafx.fxml.FXMLLoader;
5+
import javafx.scene.Parent;
6+
import javafx.scene.Scene;
7+
import javafx.stage.Stage;
8+
9+
public class Main extends Application {
10+
11+
public static void main(String[] args) {
12+
launch(args);
13+
}
14+
15+
@Override
16+
public void start(Stage primaryStage) throws Exception{
17+
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
18+
primaryStage.setTitle("Hello World");
19+
primaryStage.setScene(new Scene(root, 300, 275));
20+
primaryStage.show();
21+
}
22+
23+
24+
}

JavaFX/031_fxml/sample.fxml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<?import javafx.scene.control.*?>
3+
<?import javafx.scene.layout.*?>
4+
5+
<VBox prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml"
6+
fx:controller="sample.Controller">
7+
8+
<Label text="I love bacon"/>
9+
<Button text="Submit"/>
10+
11+
</VBox>

0 commit comments

Comments
 (0)