aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes GUI advice needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GUI advice needed" Watch "GUI advice needed" New topic
Author

GUI advice needed

JPraveen Kumar
Ranch Hand

Joined: Aug 31, 2004
Posts: 80
Hi,

My GUI requirement is as follows :

a. On start, it draws 3 circles on screen (either thro drawoval or by loading a circle image).
b. Draws lines between the circles.
c. Now I should be able to drag and move any of the circles at a time around the screen and it creates new lines from that to the other circles and kills the old lines which were initially drawn.

I have no idea how to start or how to go about doing this either by using AWT or Swing or DND. Pls advise and provide useful links

Tx Praveen.
Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
Here are some ideas.

a. On start, it draws 3 circles on screen (either thro drawoval or by loading a circle image).
sounds like you probably already know how to do this. if not, check out the Graphics API

b. Draws lines between the circles.

again, see the methods of the Graphics API.

c. Now I should be able to drag and move any of the circles at a time around the screen and it creates new lines

I hear that java supports drag and drop guis, though have never done this myself. You could [URL=http://www.google.com/search?q=java+drag+and+drop&sourceid=mozilla-search&start=0&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US fficial]google for info on this[/URL].

Alternatively, you could implement your own drag and drop operations. You would need, at a minimum:
-A datastructure modeling the circles you've drawn on the screen and their current locations.
- A datastructure modeling the end points of lines between circles.
- Mouse listeners that use the first datastructure to determine whether you've clicked in a circle and use the second data structure to update the lines between the circles.


Fun programming etcetera!
JPraveen Kumar
Ranch Hand

Joined: Aug 31, 2004
Posts: 80
Tx Dave, but i need a little more hand holding here. Some sample source code eg.

Tx Praveen.
Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
You probably ought to start with just getting some circles and some lines on the screen. You could see the examples listed under "Applet" provided at the Code Barn for info on how to draw shapes.

Also, sun's AWT tutorial is excellent.
 
Consider Paul's rocket mass heater.
 
subject: GUI advice needed