As an example of @Catalina's idea, you can use setFullScreenWindow()
, as shown here, and add the JDesktopPane
to the frame's center. Don't forget to pack()
your internal frames, too.
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
/**
* @see https://stackoverflow.com/a/13806057/230513
* @see https://stackoverflow.com/questions/7456227
*/
public class FullScreenTest {
public static final String TITLE = "Full Screen Test";
private final JFrame f = new JFrame(TITLE);
private final JDesktopPane jdp = new JDesktopPane();
public FullScreenTest() {
}
private void display() {
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice dev = env.getDefaultScreenDevice();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JInternalFrame jif = new JInternalFrame(TITLE, true, true, true);
jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.NORTH);
jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.CENTER);
jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.SOUTH);
jif.pack();
jif.setLocation(100, 100);
jif.setVisible(true);
jdp.add(jif);
f.add(jdp, BorderLayout.CENTER);
dev.setFullScreenWindow(f);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new FullScreenTest().display();
}
});
}
}