I have an applet with a main view and multiple additional pop-up JFrames. One JFrame (Report() ) takes more than 20 seconds to load because of an SQL query. I would like to display a pop-up JFrame which would warn the user, that the requested window is loading, but the content of the pop-up JFrame is displayed only after the asked JFrame was loaded.
This is the code that I have:
JFrame frame = new JFrame("Loading");
JLabel label = new JLabel("My label");
label.setFont(new java.awt.Font("Arial", 1, 16));
label.setText("<html> Please wait while </br> report loads </br>");
JPanel top = new JPanel();
top.add(label);
top.setBackground(Color.WHITE);
frame.add(top);
frame.setBackground(Color.WHITE);
frame.pack();
frame.setSize(200, 200);
frame.setVisible(true);
new Report();
In Report I do not have a main() method, I initialize it from the constructor directly with:
// setting up the cross-platform look and feel
preInitComponents();
// setting up the UI
initComponents();
// visualizing the jframe
pack();
setVisible(true);
Any suggestions what am I doing wrong?