Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #461

[Swing] Lazy sub-menu ini

From "Thomas Kellerer" <thomas.kellerer@THRWHITE.remove-dii-this>
Subject [Swing] Lazy sub-menu ini
Message-ID <4uv16uF19it44U1@mid.individual.net> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:27 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
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

---
 * 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 | Find similar


Thread

[Swing] Lazy sub-menu ini "Thomas Kellerer" <thomas.kellerer@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000

csiph-web