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

Component should trigger lostfocus event before next mousepressed event

    Details

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

      Description



      Name: jk109818 Date: 02/11/2003


      FULL PRODUCT VERSION :
      java version "1.4.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
      Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)


      FULL OPERATING SYSTEM VERSION :
      Windows 98 [Version 4.10.2222]


      A DESCRIPTION OF THE PROBLEM :
      The sequence of Mouse Pressed event and LostFocus.

      In current JDK, Mouse Pressed event will triggered first,
      and then Lost Focus.

      It should be Lost Focus first and Next Mouse pressed event.


      A JFrame contains JTextField and Jbutton. When JTextField
      lost Focus, a JOptionPane.showConfirmDialog will be show up.

      The problem is, When JTextField in focus and the cursor move
      to JButton , Press the JButton ( Don't Release). Then a
      Dialog will show up as Lost Focus event of JTextField was
      triggered.

      After return from the Dialog by click ok. The button still
      in pressed
      event when you move cursor to the button, and only change if
      another click on the button.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. click on the JTextField, let it get focus
      2. Move the cursor to JButton and press Button1 of mouse
      (don't release) on the JButton.
      3. A dialog Box will pop up, click ok to return to the frame
      where Consist of JButton.

      4. move your cursor to JButton. The JButton still in Mouse
      Press event mode, where you don't actually Press on the JButton.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The lost Focus should be triggered first, and
      Mouse Pressed next


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error Message.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import java.awt.*;
      import javax.swing.*;
      /**
       * This type was generated by a SmartGuide.
       */
      public class TestCustLib extends JFrame {
      private JPanel ivjJFrameContentPane = null;
      private JPanel ivjTestCustLibPane = null;
      IvjEventHandler ivjEventHandler = new IvjEventHandler();
      private JTextField ivjJTextField1 = null;
      private JButton ivjJButton1 = null;

      class IvjEventHandler implements java.awt.event.FocusListener {
      public void focusGained(java.awt.event.FocusEvent e) {};
      public void focusLost(java.awt.event.FocusEvent e) {
      if (e.getSource() == TestCustLib.this.getJTextField1())
      connEtoC1(e);
      };
      };
      /**
       * TestCustLib constructor comment.
       */
      public TestCustLib() {
      super();
      initialize();
      }
      /**
       * TestCustLib constructor comment.
       * @param title java.lang.String
       */
      public TestCustLib(String title) {
      super(title);
      }
      /**
       * connEtoC1: (JTextField1.focus.focusLost(java.awt.event.FocusEvent) -->
      TestCustLib.jTextField1_FocusLost(Ljava.awt.event.FocusEvent;)V)
       * @param arg1 java.awt.event.FocusEvent
       */
      /* WARNING: THIS METHOD WILL BE REGENERATED. */
      private void connEtoC1(java.awt.event.FocusEvent arg1) {
      try {
      // user code begin {1}
      // user code end
      this.jTextField1_FocusLost(arg1);
      // user code begin {2}
      // user code end
      } catch (java.lang.Throwable ivjExc) {
      // user code begin {3}
      // user code end
      handleException(ivjExc);
      }
      }
      /**
       * Return the JButton1 property value.
       * @return javax.swing.JButton
       */
      /* WARNING: THIS METHOD WILL BE REGENERATED. */
      private javax.swing.JButton getJButton1() {
      if (ivjJButton1 == null) {
      try {
      ivjJButton1 = new javax.swing.JButton();
      ivjJButton1.setName("JButton1");
      ivjJButton1.setText("JButton1");
      ivjJButton1.setBounds(60, 146, 85, 25);
      // user code begin {1}
      // user code end
      } catch (java.lang.Throwable ivjExc) {
      // user code begin {2}
      // user code end
      handleException(ivjExc);
      }
      }
      return ivjJButton1;
      }
      /**
       * Return the JFrameContentPane property value.
       * @return javax.swing.JPanel
       */
      /* WARNING: THIS METHOD WILL BE REGENERATED. */
      private javax.swing.JPanel getJFrameContentPane() {
      if (ivjJFrameContentPane == null) {
      try {
      ivjJFrameContentPane = new javax.swing.JPanel();
      ivjJFrameContentPane.setName("JFrameContentPane");
      ivjJFrameContentPane.setLayout(new java.awt.BorderLayout());
      getJFrameContentPane().add(getTestCustLibPane(), "Center");
      // user code begin {1}
      // user code end
      } catch (java.lang.Throwable ivjExc) {
      // user code begin {2}
      // user code end
      handleException(ivjExc);
      }
      }
      return ivjJFrameContentPane;
      }
      /**
       * Return the JTextField1 property value.
       * @return javax.swing.JTextField
       */
      /* WARNING: THIS METHOD WILL BE REGENERATED. */
      private javax.swing.JTextField getJTextField1() {
      if (ivjJTextField1 == null) {
      try {
      ivjJTextField1 = new javax.swing.JTextField();
      ivjJTextField1.setName("JTextField1");
      ivjJTextField1.setBounds(54, 64, 126, 20);
      // user code begin {1}
      // user code end
      } catch (java.lang.Throwable ivjExc) {
      // user code begin {2}
      // user code end
      handleException(ivjExc);
      }
      }
      return ivjJTextField1;
      }
      /**
       * Return the TestCustLibPane property value.
       * @return javax.swing.JPanel
       */
      /* WARNING: THIS METHOD WILL BE REGENERATED. */
      private javax.swing.JPanel getTestCustLibPane() {
      if (ivjTestCustLibPane == null) {
      try {
      ivjTestCustLibPane = new javax.swing.JPanel();
      ivjTestCustLibPane.setName("TestCustLibPane");
      ivjTestCustLibPane.setLayout(null);
      getTestCustLibPane().add(getJTextField1(), getJTextField1().getName());
      getTestCustLibPane().add(getJButton1(), getJButton1().getName());
      // user code begin {1}
      // user code end
      } catch (java.lang.Throwable ivjExc) {
      // user code begin {2}
      // user code end
      handleException(ivjExc);
      }
      }
      return ivjTestCustLibPane;
      }
      /**
       * Called whenever the part throws an exception.
       * @param exception java.lang.Throwable
       */
      private void handleException(java.lang.Throwable exception) {

      /* Uncomment the following lines to print uncaught exceptions to stdout */
      // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
      // exception.printStackTrace(System.out);
      }
      /**
       * Initializes connections
       * @exception java.lang.Exception The exception description.
       */
      /* WARNING: THIS METHOD WILL BE REGENERATED. */
      private void initConnections() throws java.lang.Exception {
      // user code begin {1}
      // user code end
      getJTextField1().addFocusListener(ivjEventHandler);
      }
      /**
       * Initialize the class.
       */
      /* WARNING: THIS METHOD WILL BE REGENERATED. */
      private void initialize() {
      try {
      // user code begin {1}
      // user code end
      setName("TestCustLib");
      setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
      setSize(460, 300);
      setTitle("TestCustLib");
      setContentPane(getJFrameContentPane());
      initConnections();
      } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
      }
      // user code begin {2}
      // user code end
      }
      /**
       * Comment
       */
      public void jTextField1_FocusLost(java.awt.event.FocusEvent focusEvent) {

      if (focusEvent.isTemporary())
      return;
      int li_Ok = javax.swing.JOptionPane.showConfirmDialog(this,"","",

      javax.swing.JOptionPane.DEFAULT_OPTION,javax.swing.JOptionPane.QUESTION_MESSAGE);

      return;
      }
      /**
       * Starts the application.
       * @param args an array of command-line arguments
       */
      public static void main(java.lang.String[] args) {
      try {
      /* Set native look and feel */
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      /* Create the frame */
      TestCustLib aTestCustLib = new TestCustLib();
      /* Add a windowListener for the windowClosedEvent */
      aTestCustLib.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosed(java.awt.event.WindowEvent e) {
      System.exit(0);
      };
      });
      aTestCustLib.setVisible(true);
      } catch (Throwable exception) {
      System.err.println("Exception occurred in main() of TestCustLib");
      exception.printStackTrace(System.out);
      }
      }
      }
      ---------- END SOURCE ----------
      (Review ID: 180055)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                shickeysunw Shannon Hickey (Inactive)
                Reporter:
                jkimsunw Jeffrey Kim (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: