Приложение В. Разработка приложений Java
/I Check SHIFT key
if ((event.modifiers & Event.SHIFT_MASK) \= 0) message += " + SHIFT";
graphics.drawString(message, 30, 25);
repaint() ;
return true;
}
// This routine handles the painting public void paint(Graphics graphic) ( • ,
if (output != null)
(
graphic.draw Image(output, 0, 0, this);
} }
// Implements Runnable Interface
public void run()
(
// This method is called when a new thread is started У/ (care of Runnable interface) // This is a waste of CPU resources while (true) { try
Thread.sleep(1000) ;
catch (InterruptedException e)
repaint() ;
// For running standalone
public static void main(String[] argv)
{
// Create the frame and launch simpledraw
Frame t = new Frame("simpledrawFrame");
f.reshape(100, 100, 200, 100);
f.show() ;
simpledraw x = new simpledraw();
f.add("Center", x) ;
x.init();
x.start() ;
}
// Constructor public simpledraw()
} // end class simpledraw