mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-02 16:49:10 +00:00
Merge pull request #295 from Shadowrs/bugfix/javafx-embed
Replace JavaFX-Application based UIs with FX-embedded-in-swing
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>org.parabot</groupId>
|
||||
<artifactId>client</artifactId>
|
||||
<version>2.7</version>
|
||||
<version>2.7.1</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
<dependency>
|
||||
<groupId>org.parabot</groupId>
|
||||
<artifactId>internal-api</artifactId>
|
||||
<version>1.52.1</version>
|
||||
<version>1.53.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -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,56 @@
|
||||
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.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;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* A JavaFX Panel embedded into a Swing JFrame - handles notification settings
|
||||
*
|
||||
* @author Shadowrs
|
||||
*/
|
||||
public class NotificationUI extends JavaFxUtil {
|
||||
|
||||
final NotificationUI n;
|
||||
|
||||
private NotificationUI() throws URISyntaxException, MalformedURLException {
|
||||
super(Configuration.class.getClass().getResource("/storage/ui/notifications.fxml").toURI().toURL(), NotificationUIController.class);
|
||||
this.n = this;
|
||||
}
|
||||
|
||||
public static void create() {
|
||||
try {
|
||||
new NotificationUI();
|
||||
} catch (URISyntaxException | MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="231.0"
|
||||
prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="org.parabot.core.ui.components.notifications.NotificationUIController">
|
||||
prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<bottom>
|
||||
<Button mnemonicParsing="false" text="Save" BorderPane.alignment="CENTER" onAction="#save">
|
||||
<BorderPane.margin>
|
||||
|
||||
Reference in New Issue
Block a user