Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » focusLost on a shell
focusLost on a shell [message #458557] Fri, 15 July 2005 19:07 Go to next message
Eclipse UserFriend
Originally posted by: stefan_30.gmx.net

Hi there,
i have two windows with an own shell. "Window" two has the role of a
MessageBox and will only be displayed if an error in "window" one occured.
Due to the fact of a smaller "window" two, the user has the possibility to
set the focus to the first "window" with a simple click in "window" one.
Now I added a FocusListener to "window" two and implemented the focusLost()
method. I want that "window" two stays always in the foreground of "window"
one as long as the OK-Button is pushed in "window" two.

But if I set the setFocus() method in the FocusListener of "window" two and
the "window" looses the focus, it won't be set to the foreground.
Do I have to set another method of the shell, or the display or the
composite of the window to display "window" two in the foreground???
How can I activate "window" two again???

Thanks for your help!

Stefan
Re: focusLost on a shell [message #458965 is a reply to message #458557] Wed, 27 July 2005 14:03 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Stefan,

You should not need to do a focus dance; setting the MessageBox's parent to
window1 should ensure that it stays in the foreground. Does the small
snippet below work for you? And if not, which platform are you running on?
Or have I misunderstood your question?

public static void main(String[] args) {
Display display = new Display ();
final Shell window1 = new Shell(display);
window1.setBounds(10,10,300,300);
new Button(window1, SWT.PUSH).setBounds(10,10,50,50);
window1.open();
MessageBox window2 = new MessageBox(window1, SWT.NONE);
window2.setMessage("error box");
window2.open();
while (!window1.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

Grant

"Stefan Junghans" <stefan_30@gmx.net> wrote in message
news:db91h0$1jp$1@news.eclipse.org...
> Hi there,
> i have two windows with an own shell. "Window" two has the role of a
> MessageBox and will only be displayed if an error in "window" one occured.
> Due to the fact of a smaller "window" two, the user has the possibility to
> set the focus to the first "window" with a simple click in "window" one.
> Now I added a FocusListener to "window" two and implemented the
focusLost()
> method. I want that "window" two stays always in the foreground of
"window"
> one as long as the OK-Button is pushed in "window" two.
>
> But if I set the setFocus() method in the FocusListener of "window" two
and
> the "window" looses the focus, it won't be set to the foreground.
> Do I have to set another method of the shell, or the display or the
> composite of the window to display "window" two in the foreground???
> How can I activate "window" two again???
>
> Thanks for your help!
>
> Stefan
>
>
Previous Topic:detecting right-click event on tree viewer
Next Topic:scrolling 2 texts
Goto Forum:
  


Current Time: Mon Oct 26 19:53:33 GMT 2020

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

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

Back to the top