Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-26-2007, 01:42 PM
Member
 
Join Date: Nov 2007
Posts: 7
notnumber6 is on a distinguished road
Using a cursor
Hey guys,

I want to create a basic application that imports the cross hair cursor, the overall aim of the project is to get co-ordinates depending on where the cursor is...

Any chance?

Thanks,

Joel
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-26-2007, 06:36 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
You can set the System crosshair cursor with methods in the Cursor and Component classes
Code:
Component c = your component c.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); // to change back c.setCursor(Cursor.getDefaultCursor());
Add a MouseMotionListener for mouseMoved events or a MouseListener for mousePressed events to your component and you can get the coordinates of the mouse position on the component from their MouseEvent e.getPoint.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-26-2007, 09:30 PM
Member
 
Join Date: Nov 2007
Posts: 7
notnumber6 is on a distinguished road
When you say
Code:
Component c = your component
What librarys do i need to import....

Also is C the variable name you are initialising??

So i could change it to Component crosshairCursor = your component?

Also whats your component mean....

Sorry for being thick, but a good reply hard wired
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-26-2007, 11:56 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
It was pseudo code. If I have a gui with a component displayed and I want to set the cursor for the component, ie, when the mouse is over that particular component the cursor will be set according to what I specified for the component, and if the component is:
Code:
JPanel panel = new JPanel(); // The "panel" is the reference to the Component that we use to set the cursor. // Since JPanel extends from Component we can use the (inherited) Component // method setCursor on the "panel" reference. panel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
If you do not like the System cursor you can make an image of what you want and use it with the Toolkit.createCustomCursor method to make what you want.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
GUI cursor change problem ludragon Advanced Java 2 01-09-2008 11:03 PM
How to Hide cursor priya Java Announcements 0 11-14-2007 09:27 AM


All times are GMT +3. The time now is 11:15 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org