Java Swing 启动界面
import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; import java.awt.Toolkit; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JWindow; /** * * @author Administrator */ public class WelcomeWindow extends JWindow { private int duration; Image ii; int iconWidth = 800; int iconHeight = 800; int liveTime, currTime; public WelcomeWindow(int duration) { liveTime = duration / 1000; ii = this.getToolkit().getImage("IMAGE/LOGO.png"); Dimension welcomeScreen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (welcomeScreen.width - iconWidth) / 2; int y = (welcomeScreen.height - iconHeight) / 2; currTime = liveTime; this.setBounds(x, y, iconHeight, iconHeight); this.setVisible(true); this.toFront(); } public void showWelcomeWindow() { try { repaint(); Thread.sleep(1000 * liveTime); } catch (InterruptedException ex) { Logger.getLogger(WelcomeWindow.class.getName()).log(Level.SEVERE, null, ex); } } public void showWeclomeWindowAndExit(){ this.showWelcomeWindow(); this.dispose(); } @Override public void update(Graphics g){ paint(g); } @Override public void paint(Graphics g){ g.drawImage(ii, 0, 0, this); } }
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!