Skip to main content

What's the best way implement network loader indicator ?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
stern23
Offline
Joined: 2010-10-29

Hello,
I want before connect to network to show a small png which show user loading message in middle of screen.
What's the best way to implement it?
I used to show a dialog but sometimes it shows it and never go to next command which does the internet connection.
(after I got result from network I dispose the dialog)
but as I mentioned my problem that in some cases the sreen stuck in the dialog and never go to the actual command which do the connection (so as long no connection no dispose).
I do the following:
Display.getInstance().callSerially(new Runnable() {
public void run() {
dialog = new Dialog();
....... // some code
dialog.showPacked(BorderLayout.CENTER, true);
}
});
// here I do network connection in thread - when it done I call a function which dispose the above dialog
Is any better way to implement the network loading? or what I do wrong?

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07

There are samples of this using LWUIT4IO in the IO demo app and another saple using a different approach and no LWUIT4IO in the makeover demo.
We generally just show a modeless dialog then dismiss it on completion. Make sure to make the IO on a separate thread though.