• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GUI advice needed

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
JPraveen Kumar
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tx Dave, but i need a little more hand holding here. Some sample source code eg.

Tx Praveen.
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic