CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Multi Dialogs

  1. #1
    Join Date
    Mar 2000
    Posts
    123

    Multi Dialogs

    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.


  2. #2
    Join Date
    Mar 2000
    Location
    Kaysville, UT
    Posts
    228

    Re: Multi Dialogs

    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/....html#features

    ---Splatt

    "There's nothing more dangerous than a resourceful idiot." ---Dilbert
    BWAHAHAHAHAHAHA! ---Murray

  3. #3
    Join Date
    Mar 2000
    Posts
    123

    Re: Multi Dialogs

    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!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured