0
votes

This is how i am setting a JFrame to full screen mode :

//set full screen            

frame.dispose();
frame.setUndecorated(true);
screenDevice.setFullScreenWindow(frame);
frame.setVisible(true);

//reset to window mode

frame.dispose();
screenDevice.setFullScreenWindow(null);
frame.setUndecorated(false);
frame.setVisible(true);

But, when i display any dialog, something like settings dialog, the dialog and full screen frame both lost their foucs and disappear on screen. Then i need to click in the taskbar icon to get the focus.

How to solve this issue ? Thank you.

Edit:

Suppose if there is a JMenuItem in the menu bar of this full screen window, then i am making visible a settings JDialog by clicking the menuitem like this:

settingsMenuItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        settingsDialog.showSettingsDialog();
    }
});

The settingsDialog and full screen are not showing on the screen in full screen mode. in window mode it works normally.

2

2 Answers

3
votes

If you want to set your JFrame to maximized why not use this:

frame.setExtendedState(Frame.MAXIMIZED_BOTH); 
1
votes
JFrame frame = new JFrame();   
GraphicsDevice window = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0]; 

//The number in the brackets decides what monitor the window gets "full-screened" to. 0 is the first, 1 is the second, ect.         
frame.setUndecorated(true);    
window.setFullScreenWindow(frame);    
frame.setVisible(true);    
frame.requestFocus();