944,173 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 4367
  • Java RSS
Feb 21st, 2005
0

Drawing lines by click two points

Expand Post »
I have a GUI that displays a graph and I want to have some help with a code that allows you to click a point and then another point and then it draws a line. I need some help with this because I don't know were to start.
Similar Threads
Reputation Points: 16
Solved Threads: 9
Master Poster
OurNation is offline Offline
780 posts
since Aug 2004
Feb 22nd, 2005
0

Re: Drawing lines by click two points

Dear u can do this by seving both left buton click in 2 variabli and just use drawline funcrion for drawing a line
Reputation Points: 10
Solved Threads: 0
Newbie Poster
achyut is offline Offline
11 posts
since Feb 2005
Feb 22nd, 2005
0

Re: Drawing lines by click two points

In the MouseEvent's you can do this to get the location of the click:

Event.getX();

Event.getY();

That would help you with the coordinates of where the click happened, and where you should draw the line.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Feb 22nd, 2005
0

Re: Drawing lines by click two points

ok but how is that info stored?
Reputation Points: 16
Solved Threads: 9
Master Poster
OurNation is offline Offline
780 posts
since Aug 2004
Feb 23rd, 2005
0

Re: Drawing lines by click two points

you can store it in a double:

double x1 = Event.getX();

double y2 = Event.getY();

I don't know how you are going to tell if the first points were clicked unless you use a boolean...Like that boolean is set to true if the frst points are clicked, and then set to false..If that boolean is set to false, y would then store to the points in the second set of coordinates:

double x2 = Event.getX();
double y2 = Event.getY();
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Printing from java
Next Thread in Java Forum Timeline: graphics / compiler problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC