Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2005

Tip: Looking for answers? Try searching our database.

newbie question

Thread view: 
lastninja - 21 Jan 2005 18:25 GMT
Hi
Im a beginner with Java. In few words, I need to build a GUI with 2D
graphics. The user must create one or more rectangules just inserting 4
points for each figure. Aften then, info about these figures should be
written in a XML file. Can someone suggest me something useful to do
this  (hints, tools, urls, documents, guides etc)?

thanks

GG
Roland - 22 Jan 2005 09:46 GMT
> Hi
> Im a beginner with Java. In few words, I need to build a GUI with 2D
[quoted text clipped - 6 lines]
>
> GG

Java tutorial:
<http://java.sun.com/docs/books/tutorial/>

In particlar the 2D trail:
<http://java.sun.com/docs/books/tutorial/2d/index.html>

The Java 2D guide:
<http://java.sun.com/j2se/1.5.0/docs/guide/2d/index.html>

Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \

Fahd Shariff - 23 Jan 2005 00:27 GMT
I wrote something similar to this. Well, simply put all you need to do
is listen for mouse clicks on the panel and connect them using Graphics
methods after the fourth click. Then repaint the panel.

(But obviously the four clicks might not form a rectangle. They might
form any old polygon. If you strictly want a rectangle you might have
to check the validity of the points.)

You will need to have a data model to store everything. So you need a
rectangle class and a Collection in which you can add/remove
rectangles.  After the fourth click, create a rectangle object and
store it in the collection. Then when you want to save the diagram you
can loop through the collection and generate the appropriate XML for
each rectangle.

Your XML for a diagram with rectangles might look like:

<diagram>
<rectangle x="10" y="10" width="100" height="50" />
<rectangle x="10" y="100" width="50" height="100" />
</diagram>

Hope this helps,

--
Fahd Shariff
http://www.fahdshariff.cjb.net
"Let the code do the talking... "
Andrew Thompson - 23 Jan 2005 01:33 GMT
> (But obviously the four clicks might not form a rectangle. They might
> form any old polygon. If you strictly want a rectangle you might have
> to check the validity of the points.)

A common strategy is to lock down either the X, or Y as needed.  
If you offer 'resize' bars afterwards, it is very easy and
intuitive for the end user.  They simply 'click' the box
approximately where it is used, then resize/drag to need.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.