FileDocCategorySizeDatePackage
GrayScalePanel.javaAPI DocExample1900Mon Nov 09 12:45:48 GMT 1998None

GrayScalePanel

public class GrayScalePanel extends AbstractColorChooserPanel implements ChangeListener

Fields Summary
JSlider
scale
static Color[]
grays
Constructors Summary
public GrayScalePanel()

   
    for (int i=0; i<256; i++) { grays[i] = new Color(i, i, i); }
  
    setLayout(new GridLayout(0, 1));

    // create the slider and attach us as a listener
    scale = new JSlider(JSlider.HORIZONTAL, 0, 255, 128);
    scale.addChangeListener(this);

    // Set up our display for the chooser
    add(new JLabel("Pick your shade of gray:", JLabel.CENTER));
    JPanel jp = new JPanel();
    jp.add(new JLabel("Black"));
    jp.add(scale);
    jp.add(new JLabel("White"));
    add(jp);
  
Methods Summary
protected voidbuildChooser()

 
public java.lang.StringgetDisplayName()

 return "Gray Scale"; 
public javax.swing.IcongetLargeDisplayIcon()

 return null; 
public javax.swing.IcongetSmallDisplayIcon()

 return null; 
public voidstateChanged(javax.swing.event.ChangeEvent ce)

    getColorSelectionModel().setSelectedColor(grays[scale.getValue()]);
  
public voidupdateChooser()

 
    scale.setValue(getColorSelectionModel().getSelectedColor().getRed());