aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Simple Message that doesn't require response from User? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Simple Message that doesn Watch "Simple Message that doesn New topic
Author

Simple Message that doesn't require response from User?

Malcolm Clews
Greenhorn

Joined: Aug 30, 2007
Posts: 19
Hi,

Came across this from the Developer Certification forum, as part of a post under the heading 'nx: contractor - max please help', posted by Mike Southgate with a reply from Andrew Monkhouse, back in 2003:-

Hi Mike

Is there a simple box in swing that you can show, like a dialog except that it doesn't require a user response? If there were I could just show it before I do the lock and then make it invisible when I get the lock number. Something like the JOptionPane except without the buttons...

So many options to choose from ....
You could just have a status bar at the bottom of your main window, and put a message in there telling your users what you are doing.
Or you could create a custom JOptionPane / JDialog
Or you could create a custom JWindow
Regards, Andrew


Has anyone implemented anything like the custom JOptionPane/ JDialog or custom JWindow that Andrew suggests?

I maintain an old app that includes functionality for the user to run parameterised searches. User is prompted to enter/lookup parameters to complete a dialog box. Then when they click 'OK' the action validates the input and either presents a dialog to user advising missing/invalid parameter, or displays an animated dialog showing that the search is in progress. This functionality was originally intended to run simple searches (usually single sql statements) so the validation phase is usually very quick; of late, however it has been used for some much bigger multi-sql statement searches, and for these there can be a perceptible delay between invoking the search and user seeing either an 'invalid or missing parameter' dialog or the 'animated running search' dialog. It would seem to be a nice solution to display a simple message 'Initialising Search....' or 'Validating Input.....' when the action is invoked and then hide it when validation fails/the search starts running.

My Swing knowledge isn't that deep but always willing to learn more, all advice/suggestions gratefully received,

Thanks,

Malcolm
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

there is the one that just has an OK button to close it


SCJP
Visit my download page
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
Read the section from the Swing tutorial on Concurrency. You could use a Swing Worker.

When you start your task you display the dialog. When you finish the task you hide the dialog.
Malcolm Clews
Greenhorn

Joined: Aug 30, 2007
Posts: 19
Randall/Rob,

Thanks for your replies.

Randall - is there any way you know of to not display 'OK' or any other options? - i.e. I don't want the 'dialog' aspect of the dialog box, so to speak. If not:-

Rob - the 'animated running search' dialog uses SwingWorker - I guess I can adapt that code to display a similar animated dialog for the validation phase including a 'Cancel' option on the dialog - just seemed like overkill just to display a transient informative message to the user.

Thanks again guys,

Regards,

Malcolm
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
It is not at all overkill. When you execute a long running task you should always be using a separate thread so you don't block the GUI.
Malcolm Clews
Greenhorn

Joined: Aug 30, 2007
Posts: 19
Thanks Rob - will be working with your suggestions over the next few days - Cheers Malcolm
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple Message that doesn't require response from User?