This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Hand Cursor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Hand Cursor" Watch "Hand Cursor" New topic
Author

Hand Cursor

Hasan
Greenhorn

Joined: Oct 08, 2001
Posts: 7
Our requrement is that whenever mouse is over an image, mouse cursor to be changed to hand cursor.We wrote a programe but couldn't understand as how to use it.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.Cursor.*;
/* < applet code=test2.class width=320 height=90>
< param name="but2" value="leave1.gif">
< /applet> */
public class test2 extends Applet implements MouseListener
{
Image imageb2;
int mousex;
int mousey;
public void init()
{
Cursor c=new Cursor(Cursor.HAND_CURSOR);
String imgname2=getParameter("but2");
imageb2=getImage(getDocumentBase(),imgname2);
addMouseListener(this);
}
public void mouseReleased(MouseEvent me){}
public void mouseClicked(MouseEvent me){}
public void mouseEntered(MouseEvent me)
{
mousex=me.getX();
mousey=me.getY();
// System.out.println("X CORDINATE IS "+mousex+" Y CORDINATE IS "+mousey);
if((mousex>12)&(mousex<94)&(mousey>9)&(mousey<33))
{
System.out.println("Hello");
}
}
public void mouseExited(MouseEvent me){}
public void mousePressed(MouseEvent me)
{}
public void paint(Graphics g)
{
g.drawImage(imageb2,10,10,this);
}
}

[This message has been edited by Jim Yingst (edited June 16, 2000).]
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
try this:


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Hand Cursor
 
Similar Threads
MouseMotionListener
Not able to compile
TextField Population of Mouse Events?
i'm getting an error start:applet not intialized.
HELP 5