How to focus a JFrame?

后端 未结 6 964
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 18:05

I am writing a small game, with one JFrame that holds the main game, and another JFrame that displays the score. the problem is, when I am done constructing them, the score

6条回答
  •  感情败类
    2020-12-03 18:29

    Toggle alwaysOnTop

    See here:

    http://forums.sun.com/thread.jspa?threadID=5124278

    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);
    

提交回复
热议问题