Newer
Older
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
package org.example;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Driver class for a simple JavaFX demonstration.
*
*/
public class FxmlGuiDriver extends Application {
private static final Logger log = LogManager.getLogger(FxmlGuiDriver.class);
/**
* @param args unused
*/
public static void main(String[] args) {
launch(args);
}
public void start(Stage stage) throws Exception {
log.info("Starting Hello JavaFX and Maven demonstration application");
final String fxmlFile = "/fxml/hello.fxml";
log.debug("Loading FXML for main view from: {}", fxmlFile);
final FXMLLoader loader = new FXMLLoader();
final Parent rootNode = (Parent) loader.load(getClass().getResourceAsStream(fxmlFile));
log.debug("Showing JFX scene");
final Scene scene = new Scene(rootNode, 400, 200);
//scene.getStylesheets().add("/styles/styles.css");
stage.setTitle("Hello JavaFX and Maven");
stage.setScene(scene);
stage.show();
}
}