Methods Summary |
---|
public void | actionPerformed(java.awt.event.ActionEvent e)
if ( e.getSource() == theButton ) {
changeColor();
}
|
private synchronized void | changeColor()
if ( ++colorIndex == someColors.length )
colorIndex = 0;
theButton.setForeground( currentColor() );
repaint();
|
private synchronized java.awt.Color | currentColor()
return someColors[ colorIndex ];
|
public void | init()
theMessage = getParameter("message");
theButton = new Button("Change Color");
add(theButton);
addMouseMotionListener(this);
theButton.addActionListener(this);
|
public void | mouseDragged(java.awt.event.MouseEvent e)
messageX = e.getX();
messageY = e.getY();
repaint();
|
public void | mouseMoved(java.awt.event.MouseEvent e)
|
public void | paint(java.awt.Graphics graphics)
graphics.setColor( blinkState ? Color.white : currentColor() );
graphics.drawString( theMessage, messageX, messageY );
|
public void | run()
while ( true ) {
blinkState = !blinkState;
repaint();
try {
Thread.sleep(500);
} catch (Exception e ) {
System.out.println( e );
}
}
|
public void | start()
if ( blinkThread == null ) {
blinkThread = new Thread(this);
blinkThread.start();
}
|
public void | stop()
if ( blinkThread != null ) {
blinkThread.stop();
blinkThread = null;
}
|