I have a splash screen with a label that is used as an image. I want to pause the frame to be on the screen for about 3 seconds then go to the login screen.
This is the code i'm using:
It doesn't run that thread with the sleep command. It loads and it doesn't even draw the label picture and goes directly to the login screen. Anyway I can have it load the picture and pause?Code:private void formWindowActivated(java.awt.event.WindowEvent evt) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Point startPoint = new Point(); startPoint.setLocation((screenSize.width / 3), (screenSize.height / 3)); this.setLocation(startPoint); Runnable runner = new Runnable() { public void run() { try { Thread.sleep(5000); } catch(Exception ex) { System.out.println("Error has occurred: " + ex); } } }; Thread newThread = new Thread(runner); newThread.start(); LoginFrame newLoginFrame = new LoginFrame(); newLoginFrame.setVisible(true); this.dispose(); }





Reply With Quote