0

I want to implement Java Swing Browser in JFrame, available from Net Beans Gui Builder. I've found Oracle example - working with JavaFX in Swing using J. It works, but Net Beans Gui Builder is not available in this application. I created new JFrame, available from Net Beans Gui Builder. I tried to paste WebEngine in JFXPanel (named jfxPanel) like in example, but the panel didn't appear in my JFrame during runtime (the browser was working - I got text information, but it was not visible). How to solve the problem? I suppose problem is that GUI Builder uses another Layout in initComponents and I don't know how to add my panel to JFrame.

    public SimpleSwingBrowser() {
    super();
    createScene();

    initComponents();

    panel.add(jfxPanel, BorderLayout.CENTER);
    getContentPane().add(panel);

    pack();
}

In this question it is shown how to create browser using Java Swing, but I don't know how to make it work with NetBeans GUI Builder. For example, if I comment

//initComponents(); 

in the following code

    public BrowserFrame() {
    initComponents();
}

private void initAndShowGUI() {
    // This method is invoked on the EDT thread
    //JFrame frame = new JFrame("Swing and JavaFX");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JFXPanel fxPanel = new JFXPanel();
    this.jPanel1.add(fxPanel, BorderLayout.CENTER);
    this.pack();
    this.jPanel1.setSize(640, 480);
    this.setLocationRelativeTo(null);
    this.setVisible(true);

    Platform.runLater(() -> {
        initFX(fxPanel);
    });
}

everything works, but I'm not able to comment this code, I want to use both GUI Builder and fxPanel. How is it possible to make them work together (GUI Builder generated code and fxPanel with browser)?

Community
  • 1
  • 1

0 Answers0