FileDocCategorySizeDatePackage
ScribblePane3.javaAPI DocExample2063Sat Jan 24 10:44:32 GMT 2004je3.gui

ScribblePane3

public class ScribblePane3 extends ScribblePane2
This scribble component includes a JButton to clear the screen, and a JList that lets the user select a drawing color. It uses event listener objects to handle events from those sub-components.

Fields Summary
Color[]
colors
String[]
colorNames
Constructors Summary
public ScribblePane3()


    // Add JButton and JList components to the panel.
      
	// Implicit super() call here invokes the superclass constructor

	// Add a "Clear" button to the panel.
	// Handle button events with an action listener
	JButton clear = new JButton("Clear");
	clear.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) { clear(); }
	    });
	this.add(clear);

	// Add a JList to allow color choices.
	// Handle list selection events with a ListSelectionListener.
	final JList colorList = new JList(colorNames);
	colorList.addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent e) {
		    setColor(colors[colorList.getSelectedIndex()]);
		}
	    });
	this.add(colorList);
    
Methods Summary