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; > 168c189,190 < return new DrawingViewMouseListener(); --- > mouseListener = new DrawingViewMouseListener(); > return mouseListener; 172c194,195 < return new DrawingViewMouseMotionListener(); --- > motionListener = new DrawingViewMouseMotionListener(); > return motionListener; 176c199,200 < return new DrawingViewKeyListener(); --- > keyListener = new DrawingViewKeyListener(); > return keyListener; 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; > } > } > > /**