import java.awt.*;
public class xPopup extends Window
{
int width = 100, height = 100;
Image tile = null;
Toolkit toolkit = Toolkit.getDefaultToolkit() ;
String name = "awtTips" ;
String version = "1.00" ;
String author = "R. BERTHOU" ;
String web = "http://www.javaside.com/" ;
String mail = "rbl@berthou.com" ;
xPopup()
{
super(new Frame());
setVisible(false) ;
charge("splash.jpg") ;
}
xPopup(String s)
{
super(new Frame());
setVisible(false) ;
charge(s) ;
}
public void set(String name, String version, String author, String web, String mail) {
this.name = name ;
this.version = version ;
this.author = author ;
this.web = web ;
this.mail = mail ;
}
private void charge(String s)
{
// Lecture de l'icone
MediaTracker trk = new MediaTracker(this) ;
tile = toolkit.getImage( s );
if (tile != null) {
trk.addImage(tile, 0) ;
try { trk.waitForID(0) ; }
catch ( InterruptedException e) { }
setSize(tile.getWidth(this), tile.getHeight(this)) ;
}
}
public void run( ) {
init() ;
}
public void init( )
{
Dimension dS = Toolkit.getDefaultToolkit().getScreenSize() ;
Dimension dL = getSize() ;
if (dL.width > dS.width) dL.width = dS.width ;
if (dL.height > dS.height) dL.height = dS.height ;
setLocation ( (dS.width - dL.width) / 2 , (dS.height - dL.height) / 2) ;
if(tile != null)
setVisible(true) ;
}
public void hide(int i) {
try {
Thread.sleep(i * 1000) ;
}
catch (Exception e) { }
setVisible(false) ;
}
public void paint(Graphics g)
{
int width = getSize().width, height = getSize().height, x = 0, y = 0;
if(tile != null)
g.drawImage(tile, 0, 0, getBackground(), this);
g.setColor(new Color(0xD0D0D0)) ;
g.fill3DRect(width-245, height-200, 225, 180, true);
g.setColor(new Color(0x0)) ;
g.draw3DRect(width-245, height-200, 225, 180, true);
Font f = this.getFont() ;
if (name != null) {
g.setFont(new Font("Arial",3, 18)) ;
g.drawString(name, width-230, height-175) ;
}
int Y = height-150 ;
g.setFont(f) ;
if (version != null) {
g.drawString("Version", width-235, Y) ;
g.drawString(version, width-165, Y) ;
Y += 22 ;
}
if (author != null) {
g.drawString("Author", width-235, Y) ;
g.drawString(author, width-165, Y) ;
Y += 22 ;
}
if (web != null) {
g.drawString("Url", width-235, Y) ;
g.drawString(web, width-165, Y) ;
Y += 22 ;
}
if (mail != null) {
g.drawString("E-Mail", width-235, Y) ;
g.drawString(mail, width-165, Y) ;
Y += 22 ;
}
}
}
Generated by srcColor