Two Laptop Bag
The moose likes Swing / AWT / SWT and the fly likes problem with showMessageDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with showMessageDialog" Watch "problem with showMessageDialog" New topic

problem with showMessageDialog

thejaswini ramesh
Ranch Hand

Joined: Oct 19, 2005
Posts: 74
Hi everyone,
I seem to be having trouble displaying a message dialog.My application requires user input to a textField in a specific format(say hh-mm-ss).And whenever user enters invalid i/p,a dialog should appear saying "this is the wrong format.Please enter in the format hh-mm-ss" and in the dialog there is only one button ok.when pressed the user should be prompted to enter i/p again.

I am using JOptionsPane.showMessageDialog which is showing the dialog,but my application hangs when i click ok.Can someone please help me with the listener for the ok button.
John Wetherbie

Joined: Apr 05, 2000
Posts: 1449
You may want to post your code so people may see what is going on.

The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
No listener is needed. This is almost certainly unrelated to showMessageDialog() and is a problem with the code you've written that follows it.
Dieter Merlin

Joined: Oct 25, 2005
Posts: 9
indeed. The way I validate user input is in this way:

thejaswini ramesh
Ranch Hand

Joined: Oct 19, 2005
Posts: 74
Thanks John,Ken & Dieter...well my code is way too long to post completely.I will post only part of i have written a custom dialog with ok button and a listener for tht.Please see if it makes any sense to you...I know am doing something wrong here but not able to figure it out...

Thanks for your time.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
this might be one way.

needs testing to ensure the hour range is what you want

thejaswini ramesh
Ranch Hand

Joined: Oct 19, 2005
Posts: 74
Thanks everybody...John, Ken ,Dieter & my code is working.
The basic problem seems to be the code following showMessageDialog like you suggested ken.Once again thanks to all of you.

I agree. Here's the link:
subject: problem with showMessageDialog
It's not a secret anymore!