Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Launching a JavaFX Application from Script

Featured Replies

Edit: Nevermind, got the error now:

 

Caused by: java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = pool-1-thread-2
 

 

I am having issues with launching a JavaFX application from the onStart method in Script.

There is no issue with the application itself, as it works perfectly fine when called from the main method in the same class.

 

I am launching the application using the following code, it produces "error in script onStart()", but no useful message:

@Override
public void onStart(){

    ClassName.launch(ClassName.class);
}

Thanks

Edited by Explv

You need to encapsulate it within a JFrame.

public class YourGui extends JFXPanel {

...

    public static JFrame create() {
        JFrame frame = new JFrame();
        YourGui gui = new YourGui ();
        Platform.runLater(() -> {
            gui.init();
            frame.setContentPane(gui);
        });
    }

    public void init() {
        final BorderPane container = new BorderPane();
        container.setTop(someComponent);
        container.setCenter(someOtherComponent);
        
        final Scene scene = new Scene(container);
        setScene(scene);
    }

...

}

Edit: You might only need to wrap the GuiClass.launch in a Platform.runLater

Edited by Valkyr

  • Author


Edit: You might only need to wrap the GuiClass.launch in a Platform.runLater

 

 

Just tried:

Platform.runLater(() -> ClassName.launch(ClassName.class));

But no dice, I will try your full solution now, thanks man

You need to encapsulate it within a JFrame.

public class YourGui extends JFXPanel {

...

    public static JFrame create() {
        JFrame frame = new JFrame();
        YourGui gui = new YourGui ();
        Platform.runLater(() -> {
            gui.init();
            frame.setContentPane(gui);
        });
    }

    public void init() {
        final BorderPane container = new BorderPane();
        container.setTop(someComponent);
        container.setCenter(someOtherComponent);
        
        final Scene scene = new Scene(container);
        setScene(scene);
    }

...

}

Edit: You might only need to wrap the GuiClass.launch in a Platform.runLater

 

Lool Valk he doesnt know the head ache hes getting himself into.

  • Author

You need to encapsulate it within a JFrame.

 

Got it to work by doing this. Thanks dude :)

 

Got it to work by doing this. Thanks dude smile.png

No prob, now have fun w/ styling :kappa:

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.