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 / November 2006

Tip: Looking for answers? Try searching our database.

create a GUI in java

Thread view: 
nix - 24 Nov 2006 15:20 GMT
Hi all,

I have to create a GUI in java that should have the following
functionalities:

1. load a map (bmp/jpg file) ) as background (ok this is the simplest task)
2. create objects on this map
3. delete these objects
4. drag &drop these objects on the map to put them in different positions
5. do right click on a selected object in order to set some attributes of
the object

I have no idea on how to implement these things. Does anyone have
suggestions?
Is there some free tools (in java) that do something similar so that I can
reuse the code or at least get some suggestions?

Thank you very much.
nix
RedGrittyBrick - 24 Nov 2006 20:33 GMT
> Hi all,
>
> I have to create a GUI in java that should have the following
> functionalities:

Homework?

> 1. load a map (bmp/jpg file) ) as background (ok this is the simplest task)
> 2. create objects on this map
[quoted text clipped - 5 lines]
> I have no idea on how to implement these things. Does anyone have
> suggestions?

I suggest implementing 1, since you believe it to be the simplest, then
come back here with your code and ask for a clue for 2.
Michael Rauscher - 25 Nov 2006 16:36 GMT
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


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.