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 Beginning Java and the fly likes Mouse 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 » Beginning Java
Bookmark "Mouse Cursor " Watch "Mouse Cursor " New topic
Author

Mouse Cursor

Angela Jessi
Ranch Hand

Joined: Nov 27, 2000
Posts: 428
Hi,
How to change the Mouse Cursor? If you can explain me by sample code.
Thanks in advance,
angela
Angela Jessi
Ranch Hand

Joined: Nov 27, 2000
Posts: 428
I solved it
Thanks
angela
octavyn pittman
Ranch Hand

Joined: Mar 06, 2001
Posts: 134
Angela,
Any way you could quickly describe your initial problem, and then quickly tell how you solved it?
It would be helpful to everyone here,
OP
Angela Jessi
Ranch Hand

Joined: Nov 27, 2000
Posts: 428
After I post it, I went to www.google.com. I had search on Mouse Cursor in java.
I got very good appropriate sample code.
SO I posted back that i got it..
Thanks,
angela
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
You can't post it for us??


"JavaRanch, where the deer and the Certified play" - David O'Meara
Angela Jessi
Ranch Hand

Joined: Nov 27, 2000
Posts: 428
Hi Cindy,
Definitely I can post for Javaranch.
Here is sample:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.net.*;
public class OpenPage1 extends Applet implements MouseListener
{
Label openLink;
Font f;
Cursor c;

public void init()
{
f = new Font("Serif",Font.BOLD,12);
openLink = new Label("Click Here");
openLink.setFont(f);
openLink.setForeground(Color.black);
openLink.addMouseListener(this);
add(openLink);
}
public void paint(Graphics g)
{
g.drawLine(67,29,120,29);
g.setColor(Color.red);
}
public void mouseClicked(MouseEvent e)
{
if( e.getSource() == openLink)
{
try
{
URL theURL = new URL("http://www.yahoo.com");
getAppletContext().showDocument(theURL);
}
catch(MalformedURLException me)
{
System.out.println("Bad URL: ");
}
}
}
public void mouseEntered(MouseEvent e)
{
if( e.getSource() == openLink)
{
openLink.setForeground(Color.red);
c = new Cursor ( Cursor.HAND_CURSOR );
this.setCursor (c);
}
}
public void mouseExited(MouseEvent e)
{
c = new Cursor (Cursor.DEFAULT_CURSOR );
openLink.setForeground(Color.black);
this.setCursor (c);
}
public void mouseReleased(MouseEvent e)
{}
public void mousePressed(MouseEvent e)
{}
}

Thanks,
Angela
 
 
subject: Mouse Cursor
 
Similar Threads
Mouse cursor location
Stopping cursor in position
DHTML and Javascript
Swing
mouse curser