Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with Arrays and x and y co ordinates  RSS feed

 
zenna Patel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Okay so i am a little new to this Java so i am sorry in advance if i sound a little dumb..

How can i right click on an image and store the x and y co ordinates of the right click and do the same for a left click? i was thinking that you would need to use an array, but how do i create one where the co ordinates are stored as soon as i click?

Thanks
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi zenna and welcome to the Ranch! First off, how are you displaying the image? TellTheDetails <- link

And sorry, but I don't see where an array might come into this. Coordinates are best stored in a java.awt.Point (or its equivalent in any other toolkit).
 
Campbell Ritchie
Sheriff
Posts: 53742
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You usually use x y coordinates like that on a GUI, so I shall move you to that forum.
You will probably find something very useful in the Java Tutorials. I would suggest you make the panel which the image is displayed on implement MouseListener.
 
zenna Patel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The images are stored as thumbnails (thumbPanel) on JPanel. Thanks for the help
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JPanel doesn't 'store' images, as thumbnails or otherwise. you still haven't told us how you display the images.
 
zenna Patel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry i may have misunderstood, i display my images from my c drive
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you really need to explain what you're trying to do.

e.g. do you want to display an image where
the mouse is clicked, or perhaps you want to
determine which image was selected etc.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!