public class SplashScreen extends JWindow implements Runnable {
private static int timeout = 3000; /**
* Default constructor, sets a default time of 3000 milliseconds to display
*/
public SplashScreen() {
this(timeout);
} /**
* creates a new splash screen using the given values.
* @param newTimeout maximum timeout in seconds. (can be interrupted by calling the destroy-method
*/
public SplashScreen(int newTimeout) {
try {
timeout = newTimeout;
if (timeout > 0) {
JPanel panel = new JPanel(new BorderLayout());
ImageIcon icon = new ImageIcon(SplashScreen.class.getResource("*.gif"));
panel.add(new JLabel(icon), BorderLayout.CENTER);
getContentPane().add(panel);
pack();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((int) (d.getWidth() - getWidth()) / 2, (int) (d.getHeight() - getHeight()) / 2);
}
} catch (Exception e) {
}
} /**
* @see java.lang.Runnable#run()
*/
public void run() {
if (!isShowing()) {
show();
}
try {
int secs = 1;
while (secs <= timeout) {
for(int k=0; k < 1000; k++) {
Thread.sleep(1);
}
secs++;
}
destroy();
}
catch (InterruptedException e) {
}
}
/**
* destroys the splashscreen
*/
public void destroy() {
dispose();
}
}
private static int timeout = 3000; /**
* Default constructor, sets a default time of 3000 milliseconds to display
*/
public SplashScreen() {
this(timeout);
} /**
* creates a new splash screen using the given values.
* @param newTimeout maximum timeout in seconds. (can be interrupted by calling the destroy-method
*/
public SplashScreen(int newTimeout) {
try {
timeout = newTimeout;
if (timeout > 0) {
JPanel panel = new JPanel(new BorderLayout());
ImageIcon icon = new ImageIcon(SplashScreen.class.getResource("*.gif"));
panel.add(new JLabel(icon), BorderLayout.CENTER);
getContentPane().add(panel);
pack();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((int) (d.getWidth() - getWidth()) / 2, (int) (d.getHeight() - getHeight()) / 2);
}
} catch (Exception e) {
}
} /**
* @see java.lang.Runnable#run()
*/
public void run() {
if (!isShowing()) {
show();
}
try {
int secs = 1;
while (secs <= timeout) {
for(int k=0; k < 1000; k++) {
Thread.sleep(1);
}
secs++;
}
destroy();
}
catch (InterruptedException e) {
}
}
/**
* destroys the splashscreen
*/
public void destroy() {
dispose();
}
}
解决方案 »
- 类型已定义的问题,搞不定啊!
- 求救:编译显示“无法从静态上下文中引用非静态 方法”是怎么回事
- 什么方式能同步文件?
- Struts的这两个标签有什么不同呢?
- 问一个这样的问题,数据库里有很多数据,记录设备的运行情况,怎样计算“有效小时数”和“无故障小时数”,应该怎样计算?
- 写错了一个语句, 导致数据损失, 不知道有没有办法找回修改前的数据
- 在什么地方能下载sp3、sp4补丁啊?
- 如何用JAVA调用DLL动态连接库,立马结帐!!!
- 怎样实现在服务器端的多个文件压缩打包(包括子目录)?在线等,得到答案立即结贴
- 我是java菜鸟,向大家请教
- 请问哪里可以下载visibroker??(好的连接马上给分)
- 关于character array初始化的问题
//frameApp是包名