daileyps
September 20th, 2000, 12:24 PM
Any way to pop up a dialog box (warning) from another dialog box (input)? Want to tell user a field is required if they exit out of it without entering a value.
|
Click to See Complete Forum and Search --> : Multi Dialogs daileyps September 20th, 2000, 12:24 PM Any way to pop up a dialog box (warning) from another dialog box (input)? Want to tell user a field is required if they exit out of it without entering a value. Splatt September 20th, 2000, 12:36 PM An easy way to do it is to use predefined JDialogs. For example, if you want to check to make sure that the user entered his username, you could use the following: userName = uname.getText(); if (userName.equals(null) || userName.equals("") || userName.equals(" ")) { JOptionPane.showMessageDialog(nameDialog, "Please enter a valid user name.", "Invalid User Name", JOptionPane.WARNING_MESSAGE); } //end if You can find more info about these at: http://web2.java.sun.com/docs/books/tutorial/uiswing/components/dialog.html#features ---Splatt "There's nothing more dangerous than a resourceful idiot." ---Dilbert daileyps September 20th, 2000, 03:55 PM Thanks, this is what I was doing, but getting my warning dialog twice. I've added a condition: if( ! e.isTemporary() ) { and also code to reset focus after calling the dialog: SwingUtilities.invokeLater (new Runnable () { public void run() { ((JTextField)focusObject).requestFocus(); } }); and all is well! codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |