Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mouse Cursor

 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How to change the Mouse Cursor? If you can explain me by sample code.
Thanks in advance,
angela
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved it
Thanks
angela
 
octavyn pittman
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't post it for us??
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic