import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="Banner5" width=500 height=500>
</applet>
*/
public class Banner5 extends Applet implements Runnable,MouseListener,MouseMotionListener{
Thread t = null;
Thread t1 = null;
int x,y,state;
boolean stopFlag,st1;
// Set colors and initialize thread.
public void init() {
setBackground(Color.cyan);
setForeground(Color.red);
addMouseListener(this);
addMouseMotionListener(this);
}
public void mouseClicked(MouseEvent me)
{
t1 = new Thread(this);
stopFlag = false;
t1.start();
}
public void mouseEntered(MouseEvent me)
{
t = new Thread(this);
stopFlag = false;
t.start();
}
public void mouseExited(MouseEvent me)
{
stopFlag = true;
st1=true;
showStatus("Exited");
}
public void mousePressed(MouseEvent me)
{}
public void mouseReleased(MouseEvent me)
{}
public void mouseMoved(MouseEvent me)
{
//repaint();
showStatus("hello");
}
public void run() {
char ch;
for( ; ; ) {
try {
repaint();
Thread.sleep(300);
x=x+10;
y=y+10;
if(stopFlag)
break;
} catch(InterruptedException e) {}
}
}
public void mouseDragged(MouseEvent me)
{
}
// Start thread
public void start() {
t = new Thread(this);
stopFlag = true;
t.start();
x=0;
}
// Pause the banner.
public void stop() {
stopFlag = true;
t = null;
}
// Display the banner.
public void paint(Graphics g) {
g.fillArc(100, 40, 100, 100, 0+x, 45);
g.fillArc(100, 40, 100, 100, 120+x, 45);
g.fillArc(100, 40, 100, 100, 240+x, 45);
g.fillArc(100, 200, 100, 100, 240-y, 45);
g.fillArc(100, 200, 100, 100, 120-y,45);
g.fillArc(100, 200, 100, 100, 0-y, 45);
}
}