• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple Message that doesn't require response from User?

 
Malcolm Clews
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4469
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is the one that just has an OK button to close it
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob - will be working with your suggestions over the next few days - Cheers Malcolm
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic