/*
 * JLabelGaveGrave.java
 *
 * Created on 5 mars 2008, 9:52
 * 
 */

package gavegrave;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

/**
 * JLabelGaveGrave est un JLabel clignotant. 
 * La couleur de fond ainsi que la couleur du texte clignote et 
 * change de couleurs ... c'est énervant. 
 *
 * @author pit
 */
public class JLabelGaveGrave extends JLabel {
    
    private Font font ;
    private Thread tChangeForeground ; 
    private Thread tChangeBackground ; 
    private static final int DEFAULT_SIZE = 40 ;
    
    /** 
     * Creates a new instance of JLabelGaveGrave.
     * Permet d'afficher un label hideux.
     * @param s la chaine à afficher
     */
    public JLabelGaveGrave(String s) {
        this(s,DEFAULT_SIZE);
    }
    
    /** 
     * Creates a new instance of JLabelGaveGrave.
     * Permet d'afficher un label hideux.
     * @param s la chaine à afficher
     * @param size la taille du texte à afficher
     */
    public JLabelGaveGrave(String s, int size) {
        super(s) ;
        this.font = new Font(Font.SANS_SERIF,Font.BOLD,size);
        this.setFont(font);  
        // Permet de voir la couleur du background. 
        this.setOpaque(true);
        tChangeForeground = new ThreadChangeForeground(this) ;         
        tChangeForeground.start() ;
        tChangeBackground = new ThreadChangeBackground(this) ; 
        tChangeBackground.start() ; 
    }
    
    
    /**
     * Permet simplement de tester le JLabelGaveGrave.
     * @param args the command line arguments 
     */
    public static void main(String[] args) {
        JFrame gui = new JFrame("Test du JLabelGaveGrave");          
        JLabel lblGaveGrave = new JLabelGaveGrave("Ça gave grave !",80);
        gui.add(lblGaveGrave, BorderLayout.CENTER) ;
        gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        gui.pack() ;
        gui.setVisible(true);
    }
    
}
