Replace JavaFX-Application based UIs with FX-embedded-in-swing

This commit is contained in:
Shadowrs
2018-12-09 12:26:24 +00:00
parent 930a23b558
commit aed8cd012b
5 changed files with 46 additions and 20 deletions
+1 -2
View File
@@ -1,6 +1,5 @@
package org.parabot.core.ui;
import javafx.application.Application;
import org.parabot.core.Configuration;
import org.parabot.core.Context;
import org.parabot.core.Directories;
@@ -248,7 +247,7 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
Directories.clearCache();
break;
case "Notifications":
Application.launch(NotificationUI.class);
NotificationUI.create();
break;
default:
System.out.println("Invalid command: " + command);
@@ -1,20 +1,48 @@
package org.parabot.core.ui.components.notifications;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import org.parabot.core.Configuration;
import org.parabot.api.output.Verboser;
import org.parabot.api.ui.JavaFxUtil;
public class NotificationUI extends Application {
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* A JavaFX Panel embedded into a Swing JFrame - handles notification settings
*
* @author Shadowrs
*/
public class NotificationUI extends JavaFxUtil {
final NotificationUI n;
private NotificationUI() {
super("/storage/ui/notifications.fxml", NotificationUIController.class);
this.n = this;
}
public static void create() {
new NotificationUI();
}
@Override
public void start(Stage stage) throws Exception {
//noinspection RedundantCast
BorderPane root = (BorderPane) FXMLLoader.load(this.getClass().getResource("/storage/ui/notifications.fxml"));
stage.setTitle(Configuration.BOT_TITLE);
stage.setScene(new Scene(root));
stage.show();
public WindowAdapter getWindowAdapter() {
return new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
Verboser.verbose("NotificationUI closed " + e);
}
@Override
public void windowClosing(WindowEvent e) {
// Anything here. JFrame hides on exit.
Verboser.verbose("NotificationUI closing " + e);
n.getFrame().dispose();
}
};
}
@Override
protected void onLaunched() {
n.getFrame().setTitle("Notifications");
}
}
@@ -33,7 +33,7 @@ public class Environment extends org.parabot.api.io.libraries.Environment {
loadLibrary(lib, true);
}
Core.verbose("Loading server: " + desc.toString() + "...");
Core.verbose("[Environment] Loading server: " + desc.toString() + "...");
ServerParser.SERVER_CACHE.get(desc).run();
}