Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mousedown()?

Status
Not open for further replies.

Bloodraeven

Programmer
Feb 15, 2002
1
US
ok i have been staring at the code for Mousedown for a few days now and it will not seem to work for me. this is the code:
import java.awt.event.*;
import java.awt.*;
public class mouseclictest extends java.applet.Applet {
int _x=0,_y=0;
public void init () {
}
public boolean mouseDown(Event e, int x, int y) {

return true;
}
public void paint(Graphics g){
g.drawString(_x+","+_y,20,20);
}
}

every single time i try to run the code in a java applet i get a API depracation warning and it will not run in t JApplet window. Anyone have a bright idea of how to fix this?

 
hi

i've never seen this mouse handling code, perhaps u r using java 1.0. its not the way its done in java 2. if u really want a code to check mouse, here it is:

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

class mousehandler extends MouseAdapter
{
public void mousePressed(MouseEvent e)
{
(write ur painting code here)
}
}
public class mousetest extends Applet
{
public void init()
{
addMouseListener(new mousehandler());
}
public void paint(Graphics g)
{...}
}


if u want to track mouse motion, u must extend MouseMotionAdapter or implement MouseMotionListener.

luv
Karthik.



A ship is safe in the harbour, but that's not what it is meant for!!! LOL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top