Focus on a frame

Discussion in 'Java' started by Allan Valeriano, Mar 20, 2007.

  1. 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?
    Allan Valeriano, Mar 20, 2007
    #1
    1. Advertising

  2. On Mar 21, 12:52 am, "Allan Valeriano" <> wrote:
    ...
    > 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.
    Andrew Thompson, Mar 20, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason
    Replies:
    4
    Views:
    1,590
    Jason
    May 7, 2007
  2. Harald Henkel

    frame reload() -> reloaded frame gets the focus

    Harald Henkel, Nov 10, 2003, in forum: Javascript
    Replies:
    0
    Views:
    260
    Harald Henkel
    Nov 10, 2003
  3. Arvin Portlock
    Replies:
    4
    Views:
    275
    Arvin Portlock
    Jul 12, 2004
  4. Replies:
    2
    Views:
    325
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. Roger
    Replies:
    3
    Views:
    306
Loading...

Share This Page