Package nicholas.swing;
Import java.awt. *; import java.awt.event. *; import javax.swing. *;
/ ** *
Title: jsplashwindow p> *
description: Start Up window p> *
Copyright: Copyright (c) 2005 p> *
Company: ColinSoft < / p> * @author Nicholas Lin * @version beta * / public class JSplashWindow extends JWindow {private static JSplashWindow 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 jsplashwindow (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 . HEIGHT) / 2); this.setvisible (TRUE);} / ** * set close on click * Use as it Dialog * / public void setcloseonclick (boolean b) {if (b) {if (da == null) DA = new disposeadapter (); addmouseristener (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 * / private class DisposeAdapter extends MouseAdapter {public void mouseClicked (MouseEvent me) {dispose ();}} / ** * static method to set the instance * only once is premitted * / public static synchronized boolean setInstance (String user, String filename) {if (csw == null) {csw = new JSplashWindow (user, filename); return true;} return false } / ** * get the instance of jsplashwindow * @ Return jsplashwindow * / public static synchronized jsplashwindow getInstance () {Return CSW;