I wanted to embed brower into Frame.I wrote
public class MyBrowser{
public static void main(String[] args)
{
final Display display = Display.getDefault();
Frame frm = new Frame("MyBrowser");
Canvas embedded = new Canvas();
frm.add(embedded, BorderLayout.CENTER);
frm.pack();
final Shell composite = SWT_AWT.new_Shell(display, embedded);
composite.setLayout(new FillLayout(SWT.VERTICAL));
final Browser browser = installBrowser(composite, "http://www.baidu.com");
frm.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
e.getWindow().dispose();
//composite.dispose();
// display.dispose();
}
});
JTextField addr = new JTextField(80);
addr.addActionListener(new ActionListener()
{
public void actionPerformed(final ActionEvent e)
{
display.syncExec(new Runnable()
{
public void run()
{
browser.setUrl(((JTextComponent) e.getSource()).getText());
}
});
}
});
frm.add(addr, BorderLayout.NORTH);
frm.setSize(800, 600);
frm.setVisible(true);
while (frm.isDisplayable())
if (!display.readAndDispatch())
display.sleep();
// display.dispose();
}
public static Browser installBrowser(Composite parent, String homeURL)
{
Browser browser = new Browser(parent, SWT.EMBEDDED);
browser.setUrl(homeURL);
return browser;
}
}
- On Windows it works,
- On Linux, the bridge seems to work, but nothing is visible. So I want to know how to make it work on linux.