Handle hostnames with upper-case letters
[webmin.git] / file / CbColorButton.java
1 import java.awt.*;
2 import java.util.*;
3
4 /**A component for choosing a color
5  */
6 public class CbColorButton extends Panel implements CbButtonCallback,
7                                                     CbColorWindowCallback
8 {
9         Color col;
10         CbButton but;
11         Vector pal;
12         Image swatch = Util.createImage(32, 16);
13         Graphics g = swatch.getGraphics();
14         CbColorWindow win;
15
16         CbColorButton(Color c)
17         {
18         this(c, new Vector());
19         }
20
21         CbColorButton(Color c, Vector p)
22         {
23         if (c == null) c = Color.black;
24         col = c;
25         g.setColor(col); g.fillRect(0, 0, 32, 16);
26         setLayout(new BorderLayout());
27         add("Center", but = new CbButton(swatch, this));
28         }
29
30         public void click(CbButton b)
31         {
32         if (win == null)
33                 win = new CbColorWindow(col, this);
34         }
35
36         public void chosen(CbColorWindow w, Color c)
37         {
38         if (c != null) {
39                 col = c;
40                 g.setColor(col); g.fillRect(0, 0, 32, 16);
41                 but.repaint();
42                 }
43         win = null;
44         }
45
46         public Vector palette(CbColorWindow w)
47         {
48         return pal;
49         }
50 }
51