开源代码:JSplashWindow
package nicholas.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* <p>title: (sun企业级应用的首选)lashwindow</p>
* <p>description: start up window</p>
* <p>copyright: copyright (c) 2005</p>
* <p>company: colinsoft</p>
* @author nicholas lin
* @version beta
*/
public class jsp(sun企业级应用的首选)lashwindow extends jwindow {
private static jsp(sun企业级应用的首选)lashwindow csw;
private image image;
private string user;
private string lab;
private int x1 = 155;
private int y1 = 220;
private int x2 = 250;
private int y2 = 235;
private disposeadapter da;
/**
*constructor
*/
private jsp(sun企业级应用的首选)lashwindow(string u, string filename) {
setcursor(cursor.getpredefinedcursor(cursor.wait_cursor));
imageicon icon = new imageicon(getclass().getresource(filename));
image = icon.getimage();
user = "";
user = u;
setalwaysontop(true);
setsize(icon.geticonwidth(),icon.geticonheight());
dimension screen = gettoolkit().getscreensize();
setlocation((screen.width-getsize().width)/2, (screen.height-getsize().height)/2);
this.setvisible(true);
}
/**
*set close on click
*use as about dialog
*/
public void setcloseonclick(boolean b) {
if(b) {
if(da==null)
da = new disposeadapter();
addmouselistener(da);
} else if(da!=null) {
this.removemouselistener(da);
}
}
/**
*set the place where user name will be show
*/
public void setuserlocation(int x,int y) {
x1 = x;
y1 = y;
}
/**
*set the place where status will be show
*/
public void setstatuslocation(int x,int y) {
x2 = x;
y2 = y;
}
/**
*paint
*/
public void paint(graphics g) {
g.drawimage(image,0,0,this);
g.drawstring(user,x1,y1);
if(lab!=null)
g.drawstring(lab,x2,y2);
}
/**
*set the status text
*/
public void settext(string lab) {
this.lab = lab;
repaint();
}
/**
*inner class
*to close the jwindow on click