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);