I would suggest creating a simple JDialog and then deleting it after running your code. You can create your JDialog with the following code:
JDialog dialog = new JDialog(); JLabel label = new JLabel("Please wait..."); dialog.setLocationRelativeTo(null); dialog.setTitle("Please Wait..."); dialog.add(label); dialog.pack();
And implement it as follows:
dialog.setVisible(true); // show the dialog on the screen // Do something here dialog.setVisible(false); // set visibility to false when the code has run
source share