Jimmeh Posted March 16, 2022 Share Posted March 16, 2022 (edited) 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 March 16, 2022 by Jimmeh Code Formatting Quote Link to comment Share on other sites More sharing options...
Jimmeh Posted March 16, 2022 Author Share Posted March 16, 2022 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.