I know there are bunch of similar topics, but I can't apply these solutions to my Project.
I've got a huge Java Application in which there are many time consuming operations on database. Everything is realized in a single thread so when the program is querying database the UI hangs. I got a task to make a loading window in described situations. I've tried JWindow
objects, JFrame
which is always on top, modal dialog, but none of them managed to work.
Here is the thing:
I've got JDialog
which contains JPanel
. The panel consists of 2 input fields (login
and password
) and Log in button. When user press Logs in, there (on top) should appear "Loading..."
window. Dialog is modal and is alwaysOnTop
.
How should I do this?
Closest solution I get is:
JDialog modalDialog = new JDialog(dialog, "Busy", ModalityType.MODELESS);
modalDialog.add(new JLabel("Loading..."));
modalDialog.setSize(200, 150);
modalDialog.setLocationRelativeTo(dialog);
modalDialog.setVisible(true);
But the dialog doesn't draw itself well:
It contains elements from the background instead of Loading text...
After loading is done it shows Loading... text
as desired.
When I add
modalDialog.setUndecorated(true);
It doesn't draw on the first plane... and I don't want a bar with [X]