AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Swing] Lazy sub-menu initialization

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Thomas Kellerer
Guest





PostPosted: Thu Dec 21, 2006 3:07 pm    Post subject: [Swing] Lazy sub-menu initialization Reply with quote



Hallo,

I have a popup menu that includes two sub-menus that are populated from
the database. As this take some time, I am not retrieving those entries
when creating the popup menu, but instead add a menuListener and in the
menuSelected() event I am retrieving the information from the database
and populate the sub-menu.

This is working fine, but I'd like to give the user some visiual
feedback that a retrieval is going on.

I did not succeed in showing an hourglass cursor by calling setCursor()
on the popup menu.

Ideally I'd like to have a "dummy" item in the sub-menu that shows
(Retrieving), and once the retrieval is finished this is then replaced
with the correct entries.

I tried this by adding the default item and kicking of the DB retrieval
in a separate thread. However the dummy entry is never shown for some
reason. I still get the lag when selecting the menu item and then the DB
items show up.

Any ideas or samples on how I could achieve this?

The menu looks like this:

+------------+
| Item 1 |
| Item 2 |
+------------+
| Submenu1 > |
| Submenu2 > |
+------------+

Where submenu1 and submenu2 are the two items that are populated from
the DB. My ultimate goal is to display it like this, when submenu1 is
selected (but not yet retrieved)

+------------+
| Item 1 |
| Item 2 |
+------------+
| Submenu1 > | +---------------+
| Submenu2 > | | Retrieving... |
+------------+ +---------------+

Once the retrieval is finished it should display

+------------+
| Item 1 |
| Item 2 |
+------------+
| Submenu1 > | +-----------+
| Submenu2 > | | Db Item 1 |
+------------+ | Db Item 2 |
| Db Item 3 |
+-----------+

Cheers
Thomas
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.