128a129,149 > /** > * Listener for mouse clicks. > */ > private MouseListener mouseListener; > > /** > * Listener for mouse movements. > */ > private MouseMotionListener motionListener; > > /** > * Listener for the keyboard. > */ > private KeyListener keyListener; > > /** > * Reflects whether the drawing view is in read-only mode (from a user's > * perspective). > */ > private boolean readOnly; > 168,168c189,189 < return new DrawingViewMouseListener(); --- > mouseListener = new DrawingViewMouseListener(); 168a190,190 > return mouseListener; 172,172c194,194 < return new DrawingViewMouseMotionListener(); --- > motionListener = new DrawingViewMouseMotionListener(); 172a195,195 > return motionListener; 176a200,200 > return keyListener; 176,176c199,199 < return new DrawingViewKeyListener(); --- > keyListener = new DrawingViewKeyListener(); 1095a1120,1150 > * Asks whether the drawing view is in read-only mode. If so, the user can't > * modify it using mouse or keyboard actions. Yet, it can still be modified > * from inside the program. > */ > public boolean getReadOnly() { > return readOnly; > } > > /** > * Determines whether the drawing view is in read-only mode. If so, the user can't > * modify it using mouse or keyboard actions. Yet, it can still be modified > * from inside the program. > */ > public void setReadOnly(boolean readOnly) { > if (readOnly != this.readOnly) { > if (readOnly) { > removeMouseListener(mouseListener); > removeMouseMotionListener(motionListener); > removeKeyListener(keyListener); > } > else { > addMouseListener(mouseListener); > addMouseMotionListener(motionListener); > addKeyListener(keyListener); > } > > this.readOnly = readOnly; > } > } > > /**