Reputation: 765
I am working on a Swing application that starts with JFrame, but all the other frames are included as JInternalFrames, and i am facing some serious screen size problems when i instaled it in different computers, i used the following methode to set the JFrame in full screen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0, 0, screenSize.width, screenSize.height);
JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
But I observe no difference. I also want to adjust the JInternalFrames with the screen size. If you have any suggestions or solutions, please help
Upvotes: 0
Views: 2329
Reputation: 51565
You should set the frame extended state like this:
frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
You're going to need a component listener to listen for the frame expanding to fit the screen and for resize changes.
frame.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent event) {
Dimension d = frame.getContentPane().getSize();
// code to save frame size or calculate internal frame sizes
frame.validate();
}
});
Upvotes: 3