home *** CD-ROM | disk | FTP | other *** search
/ MACD 7 / MACD7.iso / www / weirdscience / classes / colorchooser.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-06-14  |  1.6 KB  |  44 lines

  1. import java.awt.Color;
  2. import java.awt.Container;
  3. import java.awt.Dimension;
  4. import java.awt.GridLayout;
  5. import java.awt.Panel;
  6.  
  7. class ColorChooser extends Panel {
  8.    private ColorPreview preview;
  9.    private RGBChooser red;
  10.    private RGBChooser green;
  11.    private RGBChooser blue;
  12.  
  13.    public ColorChooser(ColorPreview var1, Color var2) {
  14.       this.preview = var1;
  15.       ((Container)this).setLayout(new GridLayout(3, 1));
  16.       this.red = new RGBChooser(this, "  Red", var2.getRed());
  17.       this.red.colorScroll.setBackground(Color.red);
  18.       ((Container)this).add(this.red);
  19.       this.green = new RGBChooser(this, "Green", var2.getGreen());
  20.       this.green.colorScroll.setBackground(Color.green);
  21.       ((Container)this).add(this.green);
  22.       this.blue = new RGBChooser(this, " Blue", var2.getBlue());
  23.       this.blue.colorScroll.setBackground(Color.blue);
  24.       ((Container)this).add(this.blue);
  25.       this.colorChange();
  26.    }
  27.  
  28.    public Dimension minimumSize() {
  29.       return new Dimension(120, 60);
  30.    }
  31.  
  32.    public Dimension preferredSize() {
  33.       return new Dimension(240, 120);
  34.    }
  35.  
  36.    public void colorChange() {
  37.       this.preview.setColor(this.getColor());
  38.    }
  39.  
  40.    public Color getColor() {
  41.       return new Color(this.red.getValue(), this.green.getValue(), this.blue.getValue());
  42.    }
  43. }
  44.