Java Swing 启动界面
jopen
11年前
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); } }