DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   Drawing lines by click two points (http://www.daniweb.com/forums/thread19029.html)

OurNation Feb 21st, 2005 8:54 pm
Drawing lines by click two points
 
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. ;)

achyut Feb 22nd, 2005 6:50 am
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

server_crash Feb 22nd, 2005 7:17 am
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.

OurNation Feb 22nd, 2005 10:57 pm
Re: Drawing lines by click two points
 
ok but how is that info stored?

server_crash Feb 23rd, 2005 7:05 am
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();


All times are GMT -4. The time now is 7:28 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC