926_____ ___ ,________________________Часть VI. Приложения

output = createlmage(size().width, size().height);

Graphics graphics = output.getGraphics();

graphics.setColor(Color.pink) ;

graphics. fillRect (0, 0, size () .wid.th-1, size () . height-1) ;

graphics.setCoior(Color.black) ;

repaint() ;

}

void startThread() (

if (thread == null) ( •

// Start another thread on this object);

thread = new Thread(this);

// Will ultimately cause a separate thread // to call the run method thread.start();

) }

void stopThread() (

if (thread != null) {

thread.stop() ;

thread = null;

// Mouse button pressed handling code

public boolean mouseDown(Event event, int x, int y)

(

Graphics graphics = output.getGraphics();

graphics.setColor(Color.pink);

graphics.fillRect(0, 0, size().width-1, size().height-1),

graphics.setColor(Color.black) ;

// Call to System.out for debugging System.out.printin("in mousedown") ;

System.out.printinf"Mods " + event.modifiers) ;

String message;

// Right click sets META_MASK if ((event.modifiers & Event.META_MASK) != 0)

message = new String("Right button");

else

message = new String("Left button");

// Check CTRL key

if ((event.modifiers s Event.CTRL_MASK) != 0) message += " + CTRL";