3

I am writing a java application that takes advantage of a dual monitor set up. I have two windows:

  • Window 1 - Main GUI
  • Window 2 - Full Screen on Second monitor

My Problem: The second window only stays full screen when it has the focus. If I click back on window 1 or change the focus to something else, window 2 minimizes. Is there someway to make window 2 stay full screen when it doesn't have focus?

Here is my code for making the second window full screen on the second monitor:

        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        frame.setUndecorated(true);
        frame.setVisible(true);
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] gd = ge.getScreenDevices();
        gd[1].setFullScreenWindow(frame); //gets the 2nd display.
mKorbel
  • 109,525
  • 20
  • 134
  • 319
dan.m.kumar
  • 758
  • 2
  • 9
  • 20

2 Answers2

3

Try getting the size of the second monitor then instead of setting the fullscreen monitor set the size of the the second frame. Also try setting the second frame to always on top.

TameHog
  • 950
  • 11
  • 23
  • I'll try the size thing. What do you mean by "getting the site"? and how would I set the second frame to "always on top"? Thanks! – dan.m.kumar Jul 11 '14 at 18:39
  • The site is a type. Meant to say size. Jframe has a function called always on top where no other frame can go on top. I believe it is`frame.setAlwaysOnTop(true);` – TameHog Jul 11 '14 at 18:41
  • And also you have to set the location to the width of the first screen plus one pixel and the y to 0. – TameHog Jul 11 '14 at 18:46
  • You're on to something! I tried it as you said, and it almost worked! My monitors are of different sizes so it didn't look quite right, but It still stayed active! I suppose some additional tinkering is required. – dan.m.kumar Jul 11 '14 at 19:11
1

It works with the comment from TameHog. Your code becomes:

    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setUndecorated(true);
    frame.setVisible(true);
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gd = ge.getScreenDevices();

    // gd[1].setFullScreenWindow(frame); //gets the 2nd display.
    frame.setAlwaysOnTop(true);
    frame.setSize(gd[1].getDefaultConfiguration().getBounds().getSize());
    frame.setLocation(gd[1].getDefaultConfiguration().getBounds().getLocation());
Prime541
  • 21
  • 3