Drawing lines by click two points

Reply

Join Date: Aug 2004
Posts: 780
Reputation: OurNation is an unknown quantity at this point 
Solved Threads: 9
OurNation's Avatar
OurNation OurNation is offline Offline
Master Poster

Drawing lines by click two points

 
0
  #1
Feb 21st, 2005
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.
PETA People for the Eating of Tasty Animals.


FireFox
Hijack This
Ad-Aware
Hijack this tutorial
Microsoft AntiSpyware
CompUchat
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 11
Reputation: achyut is an unknown quantity at this point 
Solved Threads: 0
achyut achyut is offline Offline
Newbie Poster

Re: Drawing lines by click two points

 
0
  #2
Feb 22nd, 2005
Dear u can do this by seving both left buton click in 2 variabli and just use drawline funcrion for drawing a line
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Drawing lines by click two points

 
0
  #3
Feb 22nd, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 780
Reputation: OurNation is an unknown quantity at this point 
Solved Threads: 9
OurNation's Avatar
OurNation OurNation is offline Offline
Master Poster

Re: Drawing lines by click two points

 
0
  #4
Feb 22nd, 2005
ok but how is that info stored?
PETA People for the Eating of Tasty Animals.


FireFox
Hijack This
Ad-Aware
Hijack this tutorial
Microsoft AntiSpyware
CompUchat
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Drawing lines by click two points

 
0
  #5
Feb 23rd, 2005
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();
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC