Java program implements the programming of the LOGO screen

xiaoxiao2021-03-06  98

Some procedures require initialization time. The program can only give the interface only after initialization, so when the program is initialized, the general software gives a picture and tells the user that the program is starting. In particular, Java interface is usually taken time. If there is no logo screen, it will make users unclear whether the program is running. In fact, many commercial procedures, such as JBuilder, give a very friendly logo screen. The principle is actually a thread of the program, and logo is a picture, so the window that shows the LOGO screen must be like a "whiteboard", that is, this window is only accommodated. There is no other maximum, minimize buttons, etc. After the program's interface is displayed, the thread of this LOGO screen is ended. The basic requirements of these LOGO pictures are very convenient to implement in Java language. A class that implements the LOGO screen will be described below. First, this class must inherit Jwindow, because Jwindow enables the effect of the window without a border. Second, this class must implement the Runnable interface of the Java language because this class itself is a thread. At the same time, this class also needs to provide the constructor of the incoming picture, and should also contain a function that makes the thread exits. The code of this class is as follows: import javax.swing. *; Import java.lang.Runnable; import java.awt. *; Public class logo extends jwindow ustements runnable {string filename; // logo Image file file name PUBLIC logo (String Name) {filename = name;} public void run () {imageicon ig = new imageicon (filename); jButton btn = new jButton (IG); // Display getContentPane (). Add (btn); // BTN will be displayed to the JPanel to Toolkit Kit = Toolkit.getDefaultToolkit (); Dimension ScreenSize = Kit.getscreensize (); // Get the size of the screen SetLocation (Screensize.Width / 4, Screensize.Height / 4); // Display the LOGO window 1/4 of the screen width, high 1/4 setsize (Ig.GeticonWidth (), Ig.GeticonHeight ()); // set the logo window size to the size TOFRONT (); // Display the LOGO window set to setvisible (true); // Display the window} public void setNotvisible () {setvisible (false); // does not display the window}} It is very convenient to use this class. For a general interface program, it is initialized when the program starts.

转载请注明原文地址:https://www.9cbs.com/read-123672.html

New Post(0)