Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » swt error opening a dialog
swt error opening a dialog [message #466353] Sun, 08 January 2006 09:00 Go to next message
Eclipse UserFriend
Originally posted by: marguu.libero.it

Opening a dialog in order to let the user insert his own values for an
element, I obtain this error:
org.eclipse.swt.SWTException: Failed to execute runnable
(java.lang.NullPointerException)
at org.eclipse.swt.SWT.error(SWT.java:2942)
at org.eclipse.swt.SWT.error(SWT.java:2865)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:126)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3057)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2716)
at
genericUMLDiagramEditor.dialogs.ContainerPropertiesInputDial og.open(ContainerPropertiesInputDialog.java:125)
I use this code in the open method:
public String open() {
// Create the dialog window
Shell shell = new Shell(getParent(), getStyle());
shell.setText(getText());
createContents(shell);
shell.setSize(400,370);
shell.setLocation(200,200);
shell.open();
Display display = getParent().getDisplay();

while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
// Return the entered value, or null
return input1;
}
I don't understand where is the problem; I use this structure in other
classes in my project and all work fine. Thanks
Re: swt error opening a dialog [message #466355 is a reply to message #466353] Sun, 08 January 2006 14:58 Go to previous messageGo to next message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
you try open dialog in non-ui thread (probably) - your display
is null - try with Display.getDefault().syncExec(...)
or in rcp PlatformUI.getWorkbench().getDisplay().sync(...)
marguu wrote:

> Opening a dialog in order to let the user insert his own values for an
> element, I obtain this error:
> org.eclipse.swt.SWTException: Failed to execute runnable
> (java.lang.NullPointerException)
> at org.eclipse.swt.SWT.error(SWT.java:2942)
> at org.eclipse.swt.SWT.error(SWT.java:2865)
> at
>
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:126)
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3057)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2716)
> at
>
genericUMLDiagramEditor.dialogs.ContainerPropertiesInputDial og.open(ContainerPropertiesInputDialog.java:125)
> I use this code in the open method:
> public String open() {
> // Create the dialog window
> Shell shell = new Shell(getParent(), getStyle());
> shell.setText(getText());
> createContents(shell);
> shell.setSize(400,370);
> shell.setLocation(200,200);
> shell.open();
> Display display = getParent().getDisplay();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> // Return the entered value, or null
> return input1;
> }
> I don't understand where is the problem; I use this structure in other
> classes in my project and all work fine. Thanks
Re: swt error opening a dialog [message #466376 is a reply to message #466355] Mon, 09 January 2006 20:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marguu.libero.it

but I don't lunch a sync (or async) runnable, symply opern the dialog (and
all my variable aren't null)
0:-(

Haris Peco wrote:

> you try open dialog in non-ui thread (probably) - your display
> is null - try with Display.getDefault().syncExec(...)
> or in rcp PlatformUI.getWorkbench().getDisplay().sync(...)
Re: swt error opening a dialog [message #466379 is a reply to message #466376] Mon, 09 January 2006 21:59 Go to previous messageGo to next message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
it is problem (probably, debug that see null variable) - you have to force
ui thread with sync/async
marguu wrote:

> but I don't lunch a sync (or async) runnable, symply opern the dialog (and
> all my variable aren't null)
> 0:-(
>
> Haris Peco wrote:
>
>> you try open dialog in non-ui thread (probably) - your display
>> is null - try with Display.getDefault().syncExec(...)
>> or in rcp PlatformUI.getWorkbench().getDisplay().sync(...)
Re: swt error opening a dialog [message #466502 is a reply to message #466353] Tue, 10 January 2006 18:40 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
The NullPointerException is being thrown by the Runnable.run() passed into
Display.asyncExec().

There should be a second error message showing the actual cause of the
NullPointerException . If not, setup debug to break on the
NullPointerException and you will see the real cause.

"marguu" <marguu@libero.it> wrote in message
news:fed32673fd40bfb0110fc6ebf7273aa7$1@www.eclipse.org...
> Opening a dialog in order to let the user insert his own values for an
> element, I obtain this error:
> org.eclipse.swt.SWTException: Failed to execute runnable
> (java.lang.NullPointerException)
> at org.eclipse.swt.SWT.error(SWT.java:2942)
> at org.eclipse.swt.SWT.error(SWT.java:2865)
> at
> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:126)
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3057)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2716)
> at
> genericUMLDiagramEditor.dialogs.ContainerPropertiesInputDial og.open(ContainerPropertiesInputDialog.java:125)
> I use this code in the open method:
> public String open() {
> // Create the dialog window
> Shell shell = new Shell(getParent(), getStyle());
> shell.setText(getText());
> createContents(shell);
> shell.setSize(400,370);
> shell.setLocation(200,200);
> shell.open();
> Display display = getParent().getDisplay();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> // Return the entered value, or null
> return input1;
> }
> I don't understand where is the problem; I use this structure in other
> classes in my project and all work fine. Thanks
>
>
Previous Topic:Table Cell Colors
Next Topic:SWT.EMBEDDED style
Goto Forum:
  


Current Time: Fri Dec 06 14:58:55 GMT 2024

Powered by FUDForum. Page generated in 0.03143 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top