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 How to change cusor and calling.......... 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 "How to change cusor and calling.........." Watch "How to change cusor and calling.........." New topic

How to change cusor and calling..........

Huzefa Zohaib
Ranch Hand

Joined: Nov 21, 2001
Posts: 40
I want to ask, that,
1) when a cursor moves on a Button component it should change into a hand cursor, how can I do that. Please give me code as an example.
2) and I have put a button which is a special one i.e "is not equal to" now I want that when on pressing that button a sign like " is equal to
with a slash on it" appears in the text field how can I do this.
basha khan
Ranch Hand

Joined: Jan 26, 2002
Posts: 516
for eg:
first create a cursor like this
java.awt.Cursor c=new java.awt.Cursor(java.awt.Curser.HAND_CURSOR);
(u can find lot of cursers in Cursor class)
then use Component class's this
now u have a hand cursor
if u need some custom cursors,try this
java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
Image img=tk.getImage("path");
java.awt.Point hotPoint = new java.awt.Point( 0, 0 );
java.awt.Cursor c=tk.createCustomCursor( img, hotPoint, "astring" );
create an image which'll become as a cursor.then create a Cursor with that image.then use setCursor method from appropriate mouseevent method.OK?
I agree. Here's the link:
subject: How to change cusor and calling..........
Similar Threads
Change the mouse cursor
Change Image Of Mouse Cursor
how to change cursor position in Swing?
Change Mouse Cursor with JTabbedPane
how to change the cursor size for dialog