Originally (See my previous question \"Java how to make JFrames start off as a maximised window\") I wanted to make a window which starts out maximised. This code accomplish
I have kind of a hack for you that might work. Try this code (it worked for me):
public static void main(String[] args) {
final JFrame frame = new JFrame("Jedia");
frame.setMinimumSize(new Dimension(600, 400));
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setVisible(true);
frame.addComponentListener(new ComponentListener(){
@Override
public void componentHidden(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentMoved(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentResized(ComponentEvent e) {
if (!e.paramString().startsWith("COMPONENT_RESIZED (-8,-8"))
frame.setSize(new Dimension(600, 400));
}
@Override
public void componentShown(ComponentEvent e) {
// TODO Auto-generated method stub
}
});
}
e.paramString() returns a String that looks like "COMPONENT_RESIZED (-8,-8, [screensize])" when a restore action takes place.