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.26k stars 192 forks source link

JFXPanel in JavaFx into the Content of the ToolWindow #359

Closed bczhaoa closed 4 months ago

bczhaoa commented 4 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 4 months ago

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