1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
package core.maj;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.util.Date;
import javax.swing.JFrame;
import com.sun.image.codec.jpeg.JPEGCodec;
import core.util.MonException;
public class MonSplashScreen extends JFrame
{
private String texte;
private Color arrierePlan;
private Color couleurTexte;
private BufferedImage img;
private final int LARGEUR;
private final int HAUTEUR_COMPLET;
private final int HAUTEUR_IMAGE;
private static final long serialVersionUID = 7121460305734206954L;
public MonSplashScreen(final String EMPLACEMENT_IMAGE, String texte) throws MonException
{
super();
try
{
this.texte = texte;
this.arrierePlan = Color.GRAY;
this.couleurTexte = Color.BLACK;
this.img = JPEGCodec.createJPEGDecoder(new BufferedInputStream(new FileInputStream(EMPLACEMENT_IMAGE))).decodeAsBufferedImage();
this.LARGEUR = this.img.getWidth(this);
this.HAUTEUR_IMAGE = this.img.getHeight(this);
this.HAUTEUR_COMPLET = this.HAUTEUR_IMAGE + 15;
this.definirPropriete();
}
catch (Exception ex)
{
throw new MonException("Pour en savoir plus reportez vous au fichier de log nommé " + new Date().toString(), ex, "Impossible de lire le fichier lifras.jpg");
}
}
public MonSplashScreen(final String EMPLACEMENT_IMAGE, Color arrierePlan, String texte) throws MonException
{
this(EMPLACEMENT_IMAGE, texte);
this.couleurTexte = Color.BLACK;
}
public MonSplashScreen(final String EMPLACEMENT_IMAGE, Color arrierePlan, Color couleurTexte, String texte) throws MonException
{
this(EMPLACEMENT_IMAGE, texte);
this.arrierePlan = arrierePlan;
this.couleurTexte = couleurTexte;
}
private void definirPropriete()
{
setSize(this.LARGEUR, this.HAUTEUR_COMPLET);
setLocationRelativeTo(getParent());
setUndecorated(true);
setFocusable(false);
setEnabled(false);
setResizable(false);
setVisible(true);
}
public void definirTexteBas(String texte)
{
this.texte = texte;
this.repaint();
}
public void definirCouleurBg(Color arrierePlan)
{
this.arrierePlan = arrierePlan;
this.repaint();
}
public void definirCouleurTexte(Color texte)
{
this.couleurTexte = texte;
this.repaint();
}
public void paint(Graphics g)
{
super.paint(g);
g.setColor(this.arrierePlan);
g.drawRect(0, 0, this.LARGEUR, this.HAUTEUR_COMPLET);
g.drawImage(this.img, 0, 0, this.LARGEUR, this.HAUTEUR_IMAGE, this);
g.setColor(this.couleurTexte);
g.drawString(this.texte, 3, this.HAUTEUR_COMPLET - 4);
}
} |
Partager