Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4490197

JButton remains pressesd when InputVerifier on JTextField shows dialog.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.3.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description



      Name: yyT116575 Date: 08/09/2001


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      When JTextField has set InputVerifier which shows dialog (reporting invalid
      input) and user puts some data into such text field and then clicks on button,
      the button remains in pressed state after dialog is closed. When you roll mouse
      over the button. If mouse pointer is outside of the button, it looks normal. The
      button sometimes behaves correctly in the first click onto button. Next try
      always brings described behaviour. It is the same on WinNT 4.0, JDK 1.3.1.


      import java.awt.*;
      import java.util.*;
      import java.awt.event.*;
      import javax.swing.*;
       
      class VerifierTest extends JFrame {

        public VerifierTest () {
          JTextField tf;
          tf = new JTextField ("Set focus here and click button.");

          getContentPane().add (tf, BorderLayout.NORTH);
          tf.setInputVerifier(new PassVerifier());

          JButton b = new JButton("JButton1");
          getContentPane().add (b, BorderLayout.SOUTH);
                        
          addWindowListener (new MyWAdapter ());
        }

        public static void main (String [] args) {
          Frame f = new VerifierTest ();
          f.pack();
          f.show();
        }

        class MyWAdapter extends WindowAdapter {
          public void windowClosing(WindowEvent event) {
            System.exit (0);
          }
        }
                     
        class PassVerifier extends InputVerifier {
          public boolean verify(JComponent input) {
            JTextField tf = (JTextField) input;
            String pass = tf.getText();
            if (pass.equals("pass")) {
              return true;
            }
            String message = "Roll over the 'JButton1' with mouse pointer "
                + "after closing this dialog.\nIt sometimes behaves correctly "
                + "for the first time\n but repeating action brings incorrect "
                + "behaviour of button.";
            JOptionPane.showMessageDialog(null, message , "invalid value",
                JOptionPane.WARNING_MESSAGE);
            return false;
          }
        }
      }
      (Review ID: 129667)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              joutwatesunw Joshua Outwater (Inactive)
              Reporter:
              yyoungsunw Yung-ching Young (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: