Focus on a frame

A

Allan Valeriano

Hi all,

how can I get a JFrame to be the focused window on top of all others?
I've tried

setAlwaysOnTop(true);
requestFocusInWindow();

but it didn't work.
I also tried

setAlwaysOnTop(true);
requestFocus();


but it seems that those aren't the right methods to do that.
Does anybody knows how can I get the frame to be on top of all others
and be the focused window?
 
A

Andrew Thompson

how can I get a JFrame to be the focused window on top of all others?
I've tried ...
I also tried

setAlwaysOnTop(true);
requestFocus();

To some extent, it depends where, when,
under what circumstances these methods
are called. A quick test here showed
no problems getting focus (Win XP, Java 6)
to the second of three JFrames using
requestFocus().
but it didn't work.

Can you provide an SSCCE that shows
this behaviour?
<http://www.physci.org/codes/sscce.html>

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top