File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes awt classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "awt classes" Watch "awt classes" New topic

awt classes

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Can anyone tell me what is wrong with the mouseDown() method of the following code. While compilation it gives a warning as "java uses or overrides a deprecated API".
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Event;
public class spots extends java.applet.Applet
final int MAXSPOTS = 10;
int xspots[] = new int[MAXSPOTS];
int yspots[] = new int[MAXSPOTS];
int currspots = 0;
public void init()
public boolean mouseDown(Event evt, int x, int y)
if ( currspots < MAXSPOTS )
return true;
System.out.println("Too many spots");
return false;
void addspot(int x, int y)
xspots[currspots] = x;
yspots[currspots] = y;

public void paint(Graphics g)
for( int i = 0; i < currspots; i++)
g.fillOval(xspots[i] - 10,yspots[i] -10,20,20);

Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
That's part of the old event model, deprecated since 1.1. It's slow, and poorly supported now. You probably want to add a MouseListener intead. Sun's Java Tutorial has examples here.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: awt classes
It's not a secret anymore!