Skip to main content

why can`t show webbrowser?

No replies
suqin
Offline
Joined: 2012-11-05
Points: 0

package SimpleBrowser;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRootPane;

import org.jdesktop.jdic.browser.WebBrowser;

public class SimpleBrowser
{

public static void main(String[] args)
{
final JFrame f = new JFrame();
JButton b = new JButton("open");
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
SimpleBrowser.create(f);
}
});
f.getContentPane().add(b);
f.setBounds(100, 100, 100, 100);
f.setVisible(true);
}

public static void create(Frame f)
{
JDialog frame = new JDialog(f, "show this");
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.INFORMATION_DIALOG);
frame.setLocation(new Point(400, 400));
final WebBrowser webBrowser = new WebBrowser();

try
{
webBrowser.setURL(new URL("http://java.net"));
}
catch (MalformedURLException e)
{
e.printStackTrace();
}

JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.setPreferredSize(new Dimension(500, 350));
panel.add(webBrowser, BorderLayout.CENTER);

frame.getContentPane().add(panel, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
}

click "open" button times,and same time can`t show any page.
why??