Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #185
| From | "Michael Rauscher" <michael.rauscher@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: create a GUI in java |
| Message-ID | <ek9rer$shj$1@registered.motzarella.org> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <ek72ln$nrt$1@newsreader.mailgate.org> |
| Date | 2011-04-27 15:26 +0000 |
| Organization | TDS.net |
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
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Find similar
create a GUI in java "nix" <nix@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000 Re: create a GUI in java "RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000 Re: create a GUI in java "Michael Rauscher" <michael.rauscher@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
csiph-web