Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Return code of window.open()
Return code of window.open() [message #443694] Wed, 29 September 2004 11:40 Go to next message
Ole Laurisch is currently offline Ole LaurischFriend
Messages: 34
Registered: July 2009
Member
Hello everybody,

I have a dialog MyDialog which extends Dialog. If I open it like this

MyDialog myDialog = new MyDialog();
myDialog.setBlockOnOpen(true);
if (myDialog.open() == Window.OK)
{
//do something
}

the if-clause returns true no matter whether I click OK in the dialog or the
small 'x' in the upper right corner of the dialog.

If I do something like this

MyDialog myDialog = new MyDialog();
myDialog.setBlockOnOpen(true);
int returnCode = myDialog.open():
System.out.println(returnCode);
if (returnCode == Window.OK)
{
//do something
}

the System.out statement prints a '1' if I click on the 'x' and and '0'
otherwise. But independent of this, the programm enters the then-part of the
if-clause.

Can anyone explain this behaviour?

Ole
Re: Return code of window.open() [message #443695 is a reply to message #443694] Wed, 29 September 2004 12:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: l.heisterkamp.web.de

Looks good to me...

Are you sure you don't have a semicolon after your if line?
if (returnCode == Window.OK);
//here --^
That would cause this behaviour.

Regards,
LH


In article <cje6m9$fbm$1@eclipse.org>, OIe.Laurisch@NOSPAMt-systems.com
says...
> Hello everybody,
>
> I have a dialog MyDialog which extends Dialog. If I open it like this
>
> MyDialog myDialog = new MyDialog();
> myDialog.setBlockOnOpen(true);
> if (myDialog.open() == Window.OK)
> {
> //do something
> }
>
> the if-clause returns true no matter whether I click OK in the dialog or the
> small 'x' in the upper right corner of the dialog.
>
> If I do something like this
>
> MyDialog myDialog = new MyDialog();
> myDialog.setBlockOnOpen(true);
> int returnCode = myDialog.open():
> System.out.println(returnCode);
> if (returnCode == Window.OK)
> {
> //do something
> }
>
> the System.out statement prints a '1' if I click on the 'x' and and '0'
> otherwise. But independent of this, the programm enters the then-part of the
> if-clause.
>
> Can anyone explain this behaviour?
>
> Ole
>
>
>
Re: Return code of window.open() [message #443697 is a reply to message #443695] Wed, 29 September 2004 12:24 Go to previous messageGo to next message
Ole Laurisch is currently offline Ole LaurischFriend
Messages: 34
Registered: July 2009
Member
Unbelievable! How did you know?
In fact there was a semicolon. And I have been debugging for half an hour...

Thanks!
Ole

"LH" <l.heisterkamp@web.de> schrieb im Newsbeitrag
news:MPG.1bc4c250d979f1d4989688@news.eclipse.org...
> Looks good to me...
>
> Are you sure you don't have a semicolon after your if line?
> if (returnCode == Window.OK);
> //here --^
> That would cause this behaviour.
>
> Regards,
> LH
>
>
> In article <cje6m9$fbm$1@eclipse.org>, OIe.Laurisch@NOSPAMt-systems.com
> says...
> > Hello everybody,
> >
> > I have a dialog MyDialog which extends Dialog. If I open it like this
> >
> > MyDialog myDialog = new MyDialog();
> > myDialog.setBlockOnOpen(true);
> > if (myDialog.open() == Window.OK)
> > {
> > //do something
> > }
> >
> > the if-clause returns true no matter whether I click OK in the dialog or
the
> > small 'x' in the upper right corner of the dialog.
> >
> > If I do something like this
> >
> > MyDialog myDialog = new MyDialog();
> > myDialog.setBlockOnOpen(true);
> > int returnCode = myDialog.open():
> > System.out.println(returnCode);
> > if (returnCode == Window.OK)
> > {
> > //do something
> > }
> >
> > the System.out statement prints a '1' if I click on the 'x' and and '0'
> > otherwise. But independent of this, the programm enters the then-part of
the
> > if-clause.
> >
> > Can anyone explain this behaviour?
> >
> > Ole
> >
> >
> >
Re: Return code of window.open() [message #443701 is a reply to message #443697] Wed, 29 September 2004 13:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: l.heisterkamp.web.de

> Unbelievable! How did you know?
> In fact there was a semicolon. And I have been debugging for half an hour...
>
> Thanks!
> Ole
;-)

In eclipse you can enable a warning to prevent such a situation:

set
Window->Preferences->Java->Compiler->Style->Empty statement
to "Warning"

Regards,
LH
Re: Return code of window.open() [message #443702 is a reply to message #443701] Wed, 29 September 2004 13:46 Go to previous message
Ole Laurisch is currently offline Ole LaurischFriend
Messages: 34
Registered: July 2009
Member
Not in WSAD 5.1 (based on Eclipse 2.1) :-(

But thanks nevertheless!


"LH" <l.heisterkamp@web.de> wrote:
> In eclipse you can enable a warning to prevent such a situation:
>
> set
> Window->Preferences->Java->Compiler->Style->Empty statement
> to "Warning"
Previous Topic:Loading PNG file with alpha channel
Next Topic:RCP JFace app sinking status bar
Goto Forum:
  


Current Time: Thu Apr 25 22:26:25 GMT 2024

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

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

Back to the top