Program Start screen

Source: Internet
Author: User

When the application starts, if the initialization time is longer, usually need to arrange a welcome to use the program's start-up interface, after the initialization is complete, the interface automatically disappears, this is what is usually said Splash window (flash windows).

/************************************************ * program file name: Jsplashwindow.java * Function: Program start interface ************************* /import javax.swing.*;import java.awt.*;import java.net.*;p ublic class Jsplashwindow extends JWindow implements Runnable{thread Splashthread = Null;public Jsplashwindow () {JPanel splash = new JPanel (New BorderLayout ()); URL Url=getclass (). GetResource ("elephant.jpg");//Add an image under the same path as the Jsplashwindow.java file, with the image name Elephant.jpgif (url!=null) {Splash.add (New JLabel (new ImageIcon (URL)), borderlayout.center);} Setcontentpane (Splash);D imension screen = Gettoolkit (). Getscreensize ();//Get the Display resolution pack (); setSize (500,400); SetLocation ((Screen.width-getsize (). width)/2, (Screen.height-getsize (). Height)/2);//To center the window}public Void Start () { This.tofront ();//The current window shows Splashthread=new Thread (this) on the front; Splashthread.start ();} public void Run () {try{show (); Thread.Sleep (3000);} catch (Exception ex) {ex.printstacktrace ();} This.dispose ();//close window}static void Showframe (String title) {JFrame frame=new JFrame (tiTLE); Frame.setsize (+); Frame.setdefaultcloseoperation (jframe.exit_on_close);D imension screensize = Toolkit.getdefaulttoolkit (). Getscreensize ();D imension framesize=frame.getsize (); if (framesize.height> Screensize.height) {framesize.height=screensize.height;} if (framesize.width>screensize.width) {framesize.width=screensize.width;} Frame.setlocation ((screensize.width-framesize.width)/2, (Screensize.height-framesize.height)/2); Label Lb=new label ("Enter Application System"), Frame.getcontentpane (). Add (lb, borderlayout.center); Lb.setfont ("Default", 1,36)); Frame.setvisible (true);} public static void Main (string[] args) {showframe ("Do splash Window"); Jsplashwindow splash=new Jsplashwindow (); Splash.start ();}}




Program Start screen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.