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
| /*
package tests;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.Timer;
/**
*
* @author Lethal
*/
public class BoutonClignotant extends JButton
{
Timer timer1;
JButton bouton;
Color tempcolor;
/** Creates a new instance of BoutonClignotant */
public BoutonClignotant(String label)
{
super(label);
bouton = this;
}
public void Clignote()
{
tempcolor = this.getBackground();
timer1 = new Timer(200, new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
bouton.setBackground(tempcolor);
timer1.stop();
}
});
this.setBackground(Color.RED);
timer1.start();
}
} |
Partager