Java/SWT/Webstart application crashes on Linux [message #529518] |
Mon, 26 April 2010 09:16 |
Eclipse User |
|
|
|
Originally posted by: txbarth.web.de
Hi,
the following code crashes on Linux (e.g. Ubuntu 9.04/9.10; Sun Java 6
installed instead of openJDK) as soon as I click the OK-Button of the
message box. But it only crashes when the application is started with
Java Webstart and I dont get any error messages!
There are no problems on Windows (XP/Vista/7) or when it is started as
application in Eclipse.
The code simply creates a shell with a button to display a message box.
Any idea how to fix it?
(Tested with SWT 3.4 and SWT 3.5)
package de.test;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import de.control.Informer;
public class HelloWorld {
private static Display display = new Display ();
private static Shell shell = new Shell(display);
public static void main(String[] args) {
Button ok = new Button (shell, SWT.PUSH);
ok.setText ("Warning");
ok.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Informer.sendWarning(HelloWorld.getShell(), "Hello Warning");
}
});
shell.setLayout(new RowLayout ());
shell.setText("Hello World Test");
shell.setSize(1024, 768);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
public static Shell getShell() {
return shell;
}
}
package de.control;
import org.eclipse.swt.SWT;
public class Informer {
public Informer() {
}
public static void sendWarning(final Shell parentShell, final String
message) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if(parentShell.isDisposed()) return;
MessageBox box = new MessageBox(parentShell, SWT.ICON_WARNING |
SWT.OK);
box.setText("Click OK and it will crash");
box.setMessage(message);
box.open();
}
});
}
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03982 seconds