-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBouton.java
More file actions
35 lines (26 loc) · 870 Bytes
/
Bouton.java
File metadata and controls
35 lines (26 loc) · 870 Bytes
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
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
//import javax.imageio.ImageIO;
import javax.swing.JButton;
public class Bouton extends JButton implements java.io.Serializable {
private String name;
public Bouton(String str){
super(str);
this.name = str;
}
public void paintComponent(Graphics g){
Graphics2D g2d = (Graphics2D)g;
GradientPaint gp = new GradientPaint(0, 0, Color.blue, 0, 20, Color.cyan, true);
g2d.setPaint(gp);
g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
g2d.setColor(Color.white);
g2d.drawString(this.name, this.getWidth() / 2 - (this.getWidth()/ 2 /4), (this.getHeight() / 2) + 5);
}
}