Find us on Google+ Kill the code: Sticky Oval in JAVA

Thursday, 22 March 2012

Sticky Oval in JAVA

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class sticky_oval extends Applet implements MouseMotionListener {
 int x,y;
 public void init() {
  addMouseMotionListener(this);
 }
 public void mouseMoved(MouseEvent me) {
  x=me.getX();
  y=me.getY();
  repaint();
 }
 public void mouseDragged(MouseEvent me) {
 
 }
 public void paint(Graphics g) {
  try {
   g.drawOval(x,y,x,y);
   if(x==y) {
    g.setColor(Color.blue);
    g.fillOval(x,y,x,y);
    showStatus("THIS IS PERFECT CIRCLE.");
    Thread.sleep(4000);
   } else showStatus("");
  } catch(InterruptedException e) {
  
  }
 }
} 

No comments:

Post a Comment