Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

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.

Featured Replies

Posted

Hi there. The past couple days I've been trying to add my own AbstractList object to my custom screen. It's been a real challenge to actually just get it to display right (of which, I still haven't managed to do). I thought I'd see if I could get JavaFX working within my project and glad to say I have. My question here is if it's possible to get the JavaFX scene to display within the game, rather than opening a separate window and pausing the game, like so (this is just a test Scene I grabbed from an old project):

https://gyazo.com/d24922903975e107fdf626899bb4aabf

If not, I'll give AbstractList another shot. Here's the relevant code:

@Mod("testmod")
public final class TestMod extends Application {
    private Stage stage;
  	
  public TestMod() {
        try {
            final Method JFXInit = JFXPanel.class.getDeclaredMethod("initFx");
            JFXInit.setAccessible(true);
            JFXInit.invoke(null);
        } catch (Exception e) {
            e.printStackTrace();
        }

        Platform.runLater(() -> {
            stage = new Stage();
        });
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        this.stage = primaryStage; //I don't believe this code is ever even reached/fired
    }

    public void display() {
        Platform.runLater(() -> {
            try {
                Scene login =  new Scene(FXMLLoader.load(getClass().getResource("/fxml/login.fxml")), 333, 316);
                this.stage.setScene(login);
                this.stage.show();
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
    }

    

I'm using reflection to call the init() method because otherwise the ToolKit isn't be initialized for JavaFX (it was one of the most upvoted solutions on StackOverflow, so I went with it). Thanks for any help!

Edited by Jimmeh
Code Formatting

  • Jimmeh changed the title to JavaFX Displayed Within Game?
  • Author

Brainstorming an idea here, not sure if it'll work. Is it possible to use a Mixin to have the Minecraft class extend Application from JavaFX? My thinking behind this is so that the Minecraft instance itself contains the Stage in which I can display the Scenes, perhaps allowing them to be displayed without forcing the game to be paused by opening separate windows. I've never used Mixins, so I'm unsure if this is possible or if it's even a good idea.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

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.