Skip to content

Commit

Permalink
Switched UI over to using SceneBuilder.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcuprak committed Apr 6, 2024
1 parent a9af6d5 commit 1dcb911
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module net.cuprak.sample {
requires javafx.controls;
requires javafx.fxml;
exports net.cuprak.sample;
}
13 changes: 13 additions & 0 deletions src/main/java/net/cuprak/sample/Controller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.cuprak.sample;

import javafx.fxml.Initializable;
import java.net.URL;
import java.util.ResourceBundle;

public class Controller implements Initializable {

@Override
public void initialize(URL location, ResourceBundle resources) {
// Initialize your controller
}
}
21 changes: 17 additions & 4 deletions src/main/java/net/cuprak/sample/JavaFXSkeletonApp.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
package net.cuprak.sample;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;
import java.util.ResourceBundle;

/**
* Skeleton Application
*/
public class JavaFXSkeletonApp extends Application {

public static void main(String[] args) {
launch();
}

@Override
public void start(Stage stage) {
stage.setTitle("Demo Application");
int width = 640;
int height = 480;
public void start(Stage stage) throws IOException {
ResourceBundle bundle = ResourceBundle.getBundle("net.cuprak.sample.resources");
FXMLLoader loader = new FXMLLoader(getClass().getResource("/net/cuprak/sample/App.fxml"),bundle);
Parent root = loader.load();
Controller controller = loader.getController();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setTitle(bundle.getString("appTitle"));
stage.show();
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/net/cuprak/sample/App.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.FlowPane?>


<FlowPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label text="%helloWorld" />
</children>
</FlowPane>
2 changes: 2 additions & 0 deletions src/main/resources/net/cuprak/sample/resources.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
helloWorld=Hello World!
appTitle=JavaFX Skeleton

0 comments on commit 1dcb911

Please sign in to comment.