0

I am using DJ-Native-Swing - JWebBrowser for displaying a browser window in a tab of JTabbedPane which also include other tabs also.
The code I am trying (on NetBeans 7.1.1) is:

browserPanel = (JPanel) SimpleWebBrowserExample.createContent(); // I use this line in browserPanel Properties > Customize Code

In the main(String[] arg) method:

NativeInterface.open();
    /*
     * Create and display the form
     */
    java.awt.EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            new MyFrame().setVisible(true);
        }
    });
NativeInterface.runEventPump();

But the code is not working, JWebBrowser is not displayed on the panel. What else I have to do for this? I am Windows 7 x64, JDK1.7.0, and I have included all the libraries required for DJ Native Swing.

Also the Standalone program is working well for me.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Asif
  • 4,980
  • 8
  • 38
  • 53

1 Answers1

0

I realise that this answer came a little bit to late but this is how I did it

Here is the class that extends JPanel and defines the browser:

   public class BrowserPanel extends JPanel {   

public  BrowserPanel() {
    super(new BorderLayout());
    JPanel webBrowserPanel = new JPanel(new BorderLayout());
    webBrowserPanel.setBorder(BorderFactory.createTitledBorder(""));
    final JWebBrowser webBrowser = new JWebBrowser();
    webBrowser.navigate("bigfarm.goodgamestudios.com/?country=RO");
    webBrowserPanel.add(webBrowser, BorderLayout.CENTER);
    add(webBrowserPanel, BorderLayout.CENTER);
  }

}

Then i've created a class that extends JFrame and holds the JTabbedPane

public class WhateverFrame extends JFrame{



    private JTabbedPane tabbedPane;



    public WhateverFrame() {


        BrowserPanel x=new BrowserPanel();

        tabbedPane = new JTabbedPane(JTabbedPane.TOP);


        tabbedPane.add(x, BorderLayout.WEST);
        tabbedPane.setTitleAt(0, "Start");
        /*
         * add the tabbedPane to the content pane
         */

        setContentPane(tabbedPane);
    }

The main looks like this:

public static void main(String[]args){ 

        UIUtils.setPreferredLookAndFeel();
        NativeInterface.open(); 
        SwingUtilities.invokeLater(new Runnable() {


        public void run() {
        WhateverFrame frame=new WhateverFrame();
                frame.setExtendedState(Frame.MAXIMIZED_BOTH);
                frame.setLocation(0,0);
                frame.setVisible(true);


          }    
        });
    }