How to bring JFrame to front?
Hi everybody,
I have a JFrame which contains a button that opens another JFrame. This second JFrame is actually already created, clicking the button will just make it visible. Does anybody know how I can move this second JFrame to the front? I tried frame.toFront(), but that didn't work.
Best regards,
Jethro Borsje
[342 byte] By [
Jethroa] at [2007-11-26 14:57:58]

# 5
I tried that, but it also does not work, here is all the code I tried:
m_frame.setVisible(true);
m_frame.toFront();
m_frame.setFocusable(true);
m_frame.setFocusableWindowState(true);
m_frame.requestFocus();
# 6
Read about toFront in the API
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Window.html#toFront
Some platforms may not permit this VM to place its Windows above windows of native applications, or Windows of other VMs.
On Windows OS for example toFront causes the icon on the Task Bar to flicker, but the window stays in the back.
The only think that will force the window to front is setAlwaysOnTop.
frame.setAlwaysOnTop(true);
frame.setAlwaysOnTop(false);
# 7
> Read about toFront in the API
> http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Windo
> w.html#toFront
>
> Some platforms may not permit this VM to place its
> Windows above windows of native applications, or
> Windows of other VMs.
>
> On Windows OS for example toFront causes the icon on
> the Task Bar to flicker, but the window stays in the
> back.
>
> The only think that will force the window to front is
> setAlwaysOnTop.
> frame.setAlwaysOnTop(true);
> frame.setAlwaysOnTop(false);
Thank you very much, that did the trick!