-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColoredToggleButton.java
More file actions
58 lines (46 loc) · 1.38 KB
/
Copy pathColoredToggleButton.java
File metadata and controls
58 lines (46 loc) · 1.38 KB
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
package aplicacion.utilerias;
import java.awt.*;
import javax.swing.*;
public class ColoredToggleButton extends JToggleButton
{
String texto;
Color verdeOscuro = new Color(12,73,11);
Color amarillo = new Color(255,203,116);
Color rojoOscuro = new Color(195,0,0);
boolean disponible = true;
public ColoredToggleButton(){
this.setForeground(Color.BLACK);
UIManager.put("ToggleButton.select", verdeOscuro);
}
@Override
public void paintComponent(Graphics g)
{
Color bg;
if(disponible){
if (isSelected()){
bg = verdeOscuro;
this.setForeground(Color.white);
//UIManager.put("ColoredToggleButton.select",Color.green);
this.setText("Selecto");
this.setBackground(bg);
super.paintComponent(g);
} else if(!isSelected()) {
bg = amarillo;
this.setForeground(Color.BLACK);
this.setText("Disponible");
this.setBackground(bg);
super.paintComponent(g);
}
}else{
this.setText("Ocupado");
this.setForeground(Color.white);
this.setBackground(rojoOscuro);
}
super.paintComponent(g);
}
public void desactivar(boolean check)
{
this.disponible = check;
this.repaint();
}
}