⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 splashwindow.java

📁 简单的学生管理系统
💻 JAVA
字号:
package catking.home.love;
/*
 *   适合应用于java Application中
 *   应用程序初始化前调用startSplash()
 *   应用程序初始化即将结束时调用stopSplash()
 *   紧接着调用应用程序的 this.setVisable(true);
 */
import java.awt.*;
import java.io.*;
import java.net.MalformedURLException;

import javax.swing.*;

public class SplashWindow extends Window{
	private String fileName;
	public SplashWindow(JFrame father,String ImageFileName)
	{
		super(father);
		this.fileName = ImageFileName;
		
	}
	public void StartSplash() 
	{
		try {
			ImageIcon splash = new ImageIcon(new File(this.fileName).toURL());
			if(splash.getIconHeight() == -1)
				this.errorHandle();
			JLabel imageLabel = new JLabel(splash);
			JPanel panel = new JPanel();
			panel.add(imageLabel);
			Dimension size = this.getToolkit().getScreenSize();
			//图片面板
			this.setLayout(new BorderLayout());
			this.add(panel,BorderLayout.CENTER);
			//设置进度条属性
			JProgressBar pb = new JProgressBar(0, 100);
			pb.setOrientation(JProgressBar.HORIZONTAL);
			pb.setForeground(Color.red);
			pb.setIndeterminate(true);
			this.add(pb,BorderLayout.SOUTH);
			
			int imgWidth = splash.getIconWidth();
			int imgHeight = splash.getIconHeight();
			this.setSize(imgWidth,imgHeight);
			this.setLocation((size.width-imgWidth)/2,(size.height-imgHeight)/2);
			
			//show window
			this.setVisible(true);
			this.toFront();
		} catch (MalformedURLException e)
		{}
	} 
	private void errorHandle()
	{
		JOptionPane.showConfirmDialog(
					this,"指定的加载图片不存在!","启动失败",JOptionPane.DEFAULT_OPTION);
		System.exit(1);
	}
	public  void stopSplash()
	{
		this.dispose();
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -