I have a Java application which has one JDesktopPane and couple of JInternalFrame. I want to load one of the JInternalFrame at startup.
I tried opening JInternalFrame from listeners of JDesktopPane, and it loads, BUT since the JDesktopPane maximizes (or does some resizing) after that, JInternalFrame sits at the top right corner with half of it not visible. How can I fix this?
EDIT:
MainWindow mainWindow = new MainWindow(); //MainWindow is a JFrame
mainWindow.setVisible(true);
//code to load JInternalFrame here
This code works when I try to debug. But when I run the application, MainWindow is maximized only after the code to load JInternalFrame is executed. I think I might add some delay or wait for the window to be maximized!
EDIT 2:
Added Thread.sleep
. Now it works fine
MainWindow mainWindow = new MainWindow(); //MainWindow is a JFrame
mainWindow.setVisible(true);
Thread.sleep(1000)
//code to load JInternalFrame here
The MainWindow constructor had setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
in it. That is somehow taking time to execute. Couldn't figure out the reason. Working fine though!