This commit is contained in:
2026-01-01 22:10:20 -05:00
parent 677efe61fa
commit 44eaeda461
5 changed files with 67 additions and 11 deletions

17
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "ApplicationView",
"request": "launch",
"mainClass": "edu.inventorym.ApplicationView",
"projectName": "UiView",
"vmArgs": " --module-path /home/sherwinp/workspace/javafx-sdk/lib --add-modules ALL-MODULE-PATH --enable-native-access=javafx.web,javafx.controls,javafx.graphics -Dcom.sun.management.jmxremote=false -Djava.awt.headless=true -XX:+DisableAttachMechanism"
},
]
}

View File

@@ -32,7 +32,7 @@ sourceSets {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/resources/media']
srcDirs = ['src/resources']
}
}
test {
@@ -64,6 +64,10 @@ dependencies {
implementation 'org.openjfx:javafx-web:25.0.1'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17'
implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.17'
implementation project(':Model')
implementation project(':Api')
}
jar {
@@ -71,7 +75,6 @@ jar {
attributes 'Main-Class': application.mainClass
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
}
tasks.named('jar') {
@@ -79,6 +82,6 @@ tasks.named('jar') {
attributes('Implementation-Title': 'edu.inventorym.UiView',
'Implementation-Version': 1.0,
'Main-Class': application.mainClass,
'Class-Path': 'lodge.reservationsystem javafx.base javafx.fxml javafx.controls javafx.graphics javafx.web com.google.gson .' )
'Class-Path': 'edu.inventorym.ApplicationView javafx.base javafx.controls javafx.graphics javafx.web .' )
}
}

View File

@@ -1,18 +1,33 @@
package edu.inventorym;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class ApplicationView extends Application {
@Override
public void start(Stage primaryStage) {
private void createWebView(Stage primaryStage, final String page) {
// create the JavaFX webview
final WebView webView = new WebView();
// show "alert" Javascript messages in stdout (useful to debug)
webView.getEngine().setOnAlert(new EventHandler<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> arg0) {
System.err.println("alertwb1: " + arg0.getData());
}
});
try {
primaryStage.setTitle("Lodge ReservationSystem");
Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("mainViewModel.fxml"));
Scene scene = new Scene(root, 800, 600);
webView.getEngine().load(
getClass().getResource(page).toExternalForm());
primaryStage.setTitle("Inventory Manager");
Scene scene = new Scene(webView, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
@@ -21,6 +36,12 @@ public class ApplicationView extends Application {
}
}
@Override
public void start(Stage primaryStage) {
final String PAGE = "/index.html";
createWebView(primaryStage, PAGE);
}
public static void main(String[] args) {
launch(args);
}

View File

@@ -0,0 +1,3 @@
body {
margin: 10px;
}

View File

@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Inventory HTML File</title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<h1>Java desktop app with Web-based UI</h1>
</body>
</html>