I'm an Eclipse newbie and I'm trying to build a mixed AWT/SWT application. Here's my code:
public class HelloWorldSWT {
public static void main(String[] args) {
Frame frame = new Frame("My AWT Frame"); // java.awt.Frame
frame.setLayout( new BorderLayout() );
Canvas canvas = new Canvas(); // java.awt.Canvas
frame.add(canvas, BorderLayout.CENTER);
frame.setVisible(true);
Display display = new Display(); // display object to manage SWT lifecycle.
Shell swtShell = SWT_AWT.new_Shell(display, canvas);
Button m_button = new Button(swtShell, SWT.PUSH);
m_button.setText( "button" );
// invoke the AWT frame rendering by making the frame visible
// This starts the EDT
frame.setVisible(true);
// standard SWT dispatch loop
while(!swtShell.isDisposed())
{
if(!display.readAndDispatch())
display.sleep();
}
swtShell.dispose();
}
}
This compiles fine, but when I run it as application in Eclipse, I get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.awt.SunToolkit.getAppContext(Ljava/lang/Object;)Lsun/awt/AppContext; at sun.awt.SunToolkit.getAppContext(Native Method) at sun.awt.SunToolkit.targetToAppContext(Unknown Source) at sun.awt.windows.WComponentPeer.postEvent(Unknown Source) at sun.awt.windows.WComponentPeer.postPaintIfNecessary(Unknown Source) at sun.awt.windows.WComponentPeer.handlePaint(Unknown Source) at sun.java2d.d3d.D3DScreenUpdateManager.repaintPeerTarget(Unknown Source) at sun.java2d.d3d.D3DScreenUpdateManager.createScreenSurface(Unknown Source) at sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown Source) at sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown Source) at sun.awt.windows.WComponentPeer.setBounds(Unknown Source) at sun.awt.windows.WWindowPeer.setBounds(Unknown Source) at sun.awt.windows.WComponentPeer.initialize(Unknown Source) at sun.awt.windows.WCanvasPeer.initialize(Unknown Source) at sun.awt.windows.WPanelPeer.initialize(Unknown Source) at sun.awt.windows.WWindowPeer.initialize(Unknown Source) at sun.awt.windows.WFramePeer.initialize(Unknown Source) at sun.awt.windows.WComponentPeer.(Unknown Source) at sun.awt.windows.WCanvasPeer.(Unknown Source) at sun.awt.windows.WPanelPeer.(Unknown Source) at sun.awt.windows.WWindowPeer.(Unknown Source) at sun.awt.windows.WFramePeer.(Unknown Source) at sun.awt.windows.WToolkit.createFrame(Unknown Source) at java.awt.Frame.addNotify(Unknown Source) at java.awt.Window.show(Unknown Source) at java.awt.Component.show(Unknown Source) at java.awt.Component.setVisible(Unknown Source) at java.awt.Window.setVisible(Unknown Source) at HelloWorldSWT.main(HelloWorldSWT.java:20)
What am I doing wrong?