| | |
manipulating graphs in a GUI
![]() |
•
•
Join Date: Nov 2004
Posts: 15
Reputation:
Solved Threads: 0
Hi, I'm creating a GUI in which users are required to interact with graphs. I have a jFrame on which I have put a jLabel and used this label to import a JPEG of a graph (i.e it's an icon). My problem is that the user needs to pick a point on the graph, and from that two coordinates will be obtained. These coordinates obviously need to corespond with the axes on the graph. How can I convert the pixel coordinates of the jLabel that the mouseClicked event will give me into coordinates that correspond to the JPEG graph? Any help is great appreciated!
Determine the top corner of the component you use to display the image and use those as an offset.
For example if the image is displayed from 100,100 on your application window and your mouse coordinates are 150,150 your coordinates in the image would be 50,50 (or was that 49,49 ...).
Mind this is just an example, I haven't checked if the coordinates in either case are calculated from the top left corner of the application window (some libraries have a tendency to calculate from the bottom right corner in which case you need the window size as well to calculate another offset to determine the top left corner).
For example if the image is displayed from 100,100 on your application window and your mouse coordinates are 150,150 your coordinates in the image would be 50,50 (or was that 49,49 ...).
Mind this is just an example, I haven't checked if the coordinates in either case are calculated from the top left corner of the application window (some libraries have a tendency to calculate from the bottom right corner in which case you need the window size as well to calculate another offset to determine the top left corner).
![]() |
Similar Threads
- manipulating gui windows (Python)
- News Story: Squish! An Automated GUI Test Tool Now For Eclipse 3.4, Qt 4.4 (Java)
- GUI problem.. (Java)
- Tkinter, GUI's, Logic... (Python)
- GUI development in LINUX (Window and Desktop Managers)
- importing graphs onto GUI frame (Java)
- Multipointer Manipulating System and Method (Computer Science)
Other Threads in the Java Forum
- Previous Thread: How to invoke array varibles to another main method
- Next Thread: Syntax Analyser and General Java Help
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle plazmic print problem program programming project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree unlimited utility webservices windows






