最近用了一下NetBeans 6.8 ,启动的时候很好看,自己模拟了一个
package flashfrm;
[code="java"]/**
*
* @author [email protected]
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws InterruptedException {
MainFrm frm = new MainFrm();
frm.setVisible(true);
//以下是测试模拟加载
Thread.sleep(1000);
frm.updateLoadInfo(10, "加载 picture....");
Thread.sleep(100);
frm.updateLoadInfo(20, "加载 数据库");
Thread.sleep(1200);
frm.updateLoadInfo(30, "加载 前台脚本");
Thread.sleep(900);
frm.updateLoadInfo(45, "加载 文件内核");
Thread.sleep(900);
frm.updateLoadInfo(66, "加载UI");
Thread.sleep(900);
frm.updateLoadInfo(86, "加载 other");
Thread.sleep(900);
frm.updateLoadInfo(100, "加载 完成");
Thread.sleep(2000);
System.exit(0);
}
}
package flashfrm;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JWindow;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
/*
* and open the template in the editor.
*/
/**
*
* @author hcmfys
*/
public class MainFrm extends JWindow {
private BufferedImage bufferImg;
private static final int IMAGE_WIDTH = 473;
private static final int IMAGE_HEIGHT = 298;
@Override
public void paint(Graphics g) {
try {
String path = this.getClass().getResource("logo.png").getPath();
bufferImg = ImageIO.read(new File(path));
g.clearRect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
g.drawImage(bufferImg, 0, 0, null);
} catch (IOException ex) {
Logger.getLogger(MainFrm.class.getName()).log(Level.SEVERE, null, ex);
}
}
public MainFrm() {
this.setSize(473, 298);
makeCenter(this);
}
public void makeCenter(Component c) {
Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
double sw = size.getWidth();
double sh = size.getHeight();
int w = c.getWidth();
int h = c.getHeight();
int left = (int) ((sw - w) / 2);
int top = (int) ((sh - h) / 2);
c.setLocation(left, top);
}
/*
* 显示进度信息
*/
public void updateLoadInfo(int value, String message) {
Graphics g = this.getGraphics();
g.setColor(Color.red);
int width = (int) (IMAGE_WIDTH * (value / (100 + 0.001)));
g.fillRect(0, 247, width, 4);
g.setColor(Color.white);
if (bufferImg != null) {
g.drawImage(bufferImg, 0, 247, 150, 15, 0, 247, 150, 15, null);
}
message += " " + value + "%";
g.drawString(message, 10, 239);
}
}