JetBrains / JetBrainsRuntime

Runtime environment based on OpenJDK for running IntelliJ Platform-based products on Windows, macOS, and Linux
GNU General Public License v2.0
1.36k stars 200 forks source link

JFXPanel in JavaFx into the Content of the ToolWindow #359

Closed bczhaoa closed 7 months ago

bczhaoa commented 7 months ago

I have embedded the JFXPanel in JavaFx into the Content of the ToolWindow. When the toolwindow is minimized and then opened, the JFXPanel disappears. The Jpanel of Swing is fine.

this is my code:

public class ToolWindowFactoryDemo implements ToolWindowFactory {
    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        System.out.println("createToolWindowContent enter.");
        ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
        Content labelContent = new ContentImpl(buildComponent3(),"Cpu&Memory", false);
        toolWindow.getContentManager().addContent(labelContent);
        labelContent.fireAlert();
    }

    private JComponent buildComponent2() { // swing test is ok

        JPanel jPanel = new JPanel();
        jPanel.add(new Button("button"));
        return jPanel;
    }

    private JComponent buildComponent3() {  // jfxPanel has this problem

        JFXPanel jfxPanel = new JFXPanel();
        System.out.println("buildComponent3 enter.");
        jfxPanel.setScene(new Scene(new javafx.scene.control.Button("button")));
        return jfxPanel;
    }
bczhaoa commented 7 months ago

add this line , it run ok: Platform.setImplicitExit(false);