My Java application working flow:
I first try to code the flow logic in Jframe's constructor. But the frame will hang on the HTTP POST stage, and doesn't show the words in [2]. After POST done, it shows the data in [5] directly.
Cause jumping the stage [2], users may think the process blocking means the something wrong, it does not do the search work.
Now I add a JOptionPane.showMessageDialog in stage[2]. It stops the process because needing a mouse click on "OK" Button in the dialog. In that moment, the panels in the frame shows the words, "keyword processing... pls waiting.".
I'd like to know why the stop point of the MessageDialog can paint the old panel, which means the words in [2]. Such as revalidate() or repaint() do not paint the old panel.
Don't block the EDT (Event Dispatch Thread). The GUI will 'freeze' when that happens. See Concurrency in Swing for details and the fix (a SwingWorker
).
BTW - Use a CardLayout
as shown in this answer for changing panels.