Java – how to create a splash screen for the GUI?
Hello, I'm a novice in Java and try to make the flash screen or image display for 3 seconds Then it will enter my main program Does anyone have an idea how to do this or can link to any tutorial?
So far, I have done this, but I don't know where to start
public static void main(String[] args) { splashInit(); // initialize splash overlay drawing parameters appInit(); // simulate what an application would do }
resolvent
Solution
The easiest way is to create a JFrame, add a screen to it, and then use thread Sleep(long millies)
Try this Code:
JWindow window = new JWindow(); window.getContentPane().add( new JLabel("",new ImageIcon(new URL("http://docs.oracle.com/javase/tutorial/uiswing/examples/misc/SplashDemoProject/src/misc/images/splash.gif")),SwingConstants.CENTER)); window.setBounds(500,150,300,200); window.setVisible(true); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } window.setVisible(false); JFrame frame = new JFrame(); frame.add(new JLabel("Welcome")); frame.setVisible(true); frame.setSize(300,100); window.dispose();
Or you can use the splashScreen class to create a splash screen
The above is the Java collected by programming house for you - how to make a startup screen for GUI? I hope this article can help you solve Java - how to make a startup screen for GUI? Program development problems encountered.
If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.