FileDocCategorySizeDatePackage
CrayonPanel.javaAPI DocExample3066Tue Dec 12 18:59:20 GMT 2000None

CrayonPanel

public class CrayonPanel extends AbstractColorChooserPanel

Fields Summary
JToggleButton
redCrayon
JToggleButton
yellowCrayon
JToggleButton
greenCrayon
JToggleButton
blueCrayon
Constructors Summary
public CrayonPanel()

        super();
    
Methods Summary
protected voidbuildChooser()

        setLayout(new GridLayout(0, 1));

        CrayonListener cl = new CrayonListener();
        ButtonGroup boxOfCrayons = new ButtonGroup();
        Border border = BorderFactory.createEmptyBorder(4,4,4,4);

        redCrayon = new JToggleButton(new ImageIcon("images/red.gif"));
        redCrayon.setActionCommand("red");
        redCrayon.addActionListener(cl);
        redCrayon.setBorder(border);
        boxOfCrayons.add(redCrayon);
        add(redCrayon);

        yellowCrayon = new JToggleButton(new ImageIcon("images/yellow.gif"));
        yellowCrayon.setActionCommand("yellow");
        yellowCrayon.addActionListener(cl);
        yellowCrayon.setBorder(border);
        boxOfCrayons.add(yellowCrayon);
        add(yellowCrayon);

        greenCrayon = new JToggleButton(new ImageIcon("images/green.gif"));
        greenCrayon.setActionCommand("green");
        greenCrayon.addActionListener(cl);
        greenCrayon.setBorder(border);
        boxOfCrayons.add(greenCrayon);
        add(greenCrayon);

        blueCrayon = new JToggleButton(new ImageIcon("images/blue.gif"));
        blueCrayon.setActionCommand("blue");
        blueCrayon.addActionListener(cl);
        blueCrayon.setBorder(border);
        boxOfCrayons.add(blueCrayon);
        add(blueCrayon);
    
public java.lang.StringgetDisplayName()

        return "Crayons";
    
public javax.swing.IcongetLargeDisplayIcon()

        return null;
    
public javax.swing.IcongetSmallDisplayIcon()

        return null;
    
public voidupdateChooser()

        Color color = getColorFromModel();
        if (color.equals(Color.red)) {
            redCrayon.setSelected(true);
        } else if (color.equals(Color.yellow)) {
            yellowCrayon.setSelected(true);
        } else if (color.equals(Color.green)) {
            greenCrayon.setSelected(true);
        } else if (color.equals(Color.blue)) {
            blueCrayon.setSelected(true);
        }