欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

一个展示启动画面的例子 JavaSwingthread 

程序员文章站 2022-07-12 23:50:21
...
其中BootPicture.java即为启动的画面 如下:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class BootPicture extends JWindow {
	private ImageIcon image = new ImageIcon(  "173.jpg"  );;


	public void paint( Graphics g ); {
		g = this.getGraphics();;
		super.paint( g );;
		g.drawImage( image.getImage();,0,0,null );;

		System.out.println( "Paint" );;
	}
	public BootPicture(); {
		Dimension screenSize = Toolkit.getDefaultToolkit();.getScreenSize();;
		this.setSize( 300,300);;
		this.setAlwaysOnTop( true );;
		int xLocation = ( screenSize.width - this.getSize();.width );/2;
		int yLocation = ( screenSize.height - this.getSize();.height );/2;
		this.setLocation( xLocation,yLocation);;
		this.setVisible( true );;
	}

	public static void main( String[] args ); {
		new BootPicture();;
	}
}


Demo.java为一个主类:
import java.awt.*;
import javax.swing.*;

public class Demo extends JFrame {
	public Demo(); {
		this.setSize( 300,300 );;
		this.setLocation( 300,300 );;
		this.setVisible( true );;
	}

	public static void main( String[] args ); {
		BootPicture boot = new BootPicture();;
		try {
			Thread.sleep( 3000 );;
		}catch( Exception e ); {
			e.printStackTrace();;
		}
		boot.dispose();;

		new Demo();;
	}
}
相关标签: Java Swing thread