Results 1 to 2 of 2
  1. #1
    bikashg is offline Member
    Join Date
    Apr 2010
    Posts
    13
    Rep Power
    0

    Default Suitable widget for drawing a 2D cartesian coordinate system in java

    Hello All,

    I want to build up a GUI area where users can click randomly. Then I want to retrieve the cartesian (x,y) coordinates of those points where the user clicked. Which GUI component is suitable for my task. Also, I want to have any point as big as a usual dot (maybe 3 pixels or more - does this depend on resolution? And if I change the screen resolution of the monitor during the program execution, does the coordinate change?)

    I usually work in web programming and I am totally novice in this area. Any pointers to good background reading would help greatly.

    Thanks.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by bikashg View Post
    Hello All,

    I want to build up a GUI area where users can click randomly. Then I want to retrieve the cartesian (x,y) coordinates of those points where the user clicked. Which GUI component is suitable for my task. Also, I want to have any point as big as a usual dot (maybe 3 pixels or more - does this depend on resolution? And if I change the screen resolution of the monitor during the program execution, does the coordinate change?)

    I usually work in web programming and I am totally novice in this area. Any pointers to good background reading would help greatly.

    Thanks.
    A JPanel can do the job; the paintComponent(Graphics g) method is actually passed a Graphics2D object. Read the API documentation for that class. It can draw in world coordinates, no matter the actual resulution (measured in pixels). It can even scale and translate the coordinate system for you so that you can work in mathematical coordinates (x moving to the right, y moving upwards).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Java Coordinate System
    By swalker326 in forum Java Applets
    Replies: 8
    Last Post: 12-05-2010, 07:39 PM
  2. Cartesian coordinate system (X > 0, Y>0)
    By cselic in forum Java 2D
    Replies: 0
    Last Post: 07-02-2010, 01:54 PM
  3. Replies: 3
    Last Post: 02-07-2010, 08:34 PM
  4. What database is more suitable to a java app?
    By hittite in forum New To Java
    Replies: 6
    Last Post: 11-14-2008, 04:33 AM
  5. X&Y Coordinate Drawing on jPanel
    By BHCluster in forum Java 2D
    Replies: 2
    Last Post: 03-27-2008, 10:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •