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]
# 1
Try setting focus on the second frame.
camickra at 2007-7-8 8:46:45 > top of Java-index,Desktop,Core GUI APIs...
# 2
I tried these two:m_frame.setFocusable(true);m_frame.setFocusableWindowState(true);They both do not work...
Jethroa at 2007-7-8 8:46:45 > top of Java-index,Desktop,Core GUI APIs...
# 3
Meep. Nothing to see here.
es5f2000a at 2007-7-8 8:46:45 > top of Java-index,Desktop,Core GUI APIs...
# 4
I meant something like frame2.requestFocus().
camickra at 2007-7-8 8:46:45 > top of Java-index,Desktop,Core GUI APIs...
# 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();

Jethroa at 2007-7-8 8:46:45 > top of Java-index,Desktop,Core GUI APIs...
# 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);

Rodney_McKaya at 2007-7-8 8:46:45 > top of Java-index,Desktop,Core GUI APIs...
# 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!

Jethroa at 2007-7-8 8:46:45 > top of Java-index,Desktop,Core GUI APIs...