Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.alt.net!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Michael Rauscher" Subject: Re: create a GUI in java Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: References: Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 59 Date: Wed, 27 Apr 2011 15:26:05 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303917965 96.60.20.240 (Wed, 27 Apr 2011 10:26:05 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:26:05 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:185 To: comp.lang.java.gui nix schrieb: > Hi all, > > I have to create a GUI in java that should have the following > functionalities: Hmm... I'll give you just some basic instructions. > 1. load a map (bmp/jpg file) ) as background (ok this is the simplest task) In fact, this are two tasks: a) load a map b) display it in the background Create a subtype of JPanel (if you want to use Swing) that is able to this (or at least b)). You'll have to override paintComponent (Swing). Perhaps you want to do a) as a separate task and to display some progress bar or something like this. > 2. create objects on this map Use an array in the created class (see above) to hold descriptions for these objects. Extend paintComponent so that the described objects are painted properly. > 3. delete these objects This is to remove the object(s) from the array and to repaint the panel. > 4. drag &drop these objects on the map to put them in different positions For this you'll have to extend your class a bit. First of all write a method that returns an object (or null) for a given point. Then implement MouseListener and MouseMotionListener. If the use clicks on an object (here you'll have to use the previous mentioned method) with the left mouse button, put the selected object into "some memory". Whenever the use drags the mouse (see MouseMotionListener#mouseDragged) update the object's description (perhaps followed by a repaint). Implement the methods that are needed to do this. > 5. do right click on a selected object in order to set some attributes of > the object Use the location retrieval method mentioned above. Update the object's description and repaint the panel afterwards. This should be enough to complete the task and to let you have some fun with it on your own. Bye Michael --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24