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

Problems with OptionPane in FocusLost

    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:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description



      Name: boT120536 Date: 12/14/2000


      JDK 1.3 final release for Windows

      Try the following test class.
      1) Set the focus into the TextField und press the button (hold down the mouse
      button for a second) or use the Mnemonic. The ActionEvent apears before the
      OptionPane opens. I think this is wrong. Move the mouse above the Button
      and it will be painted pressed if the mouse is above the button (wrong, too).
      2) Start the test and set the focus into the TextField, again. Move the mouse
      above the Button and press the mouse button very short (just a short klick).
      No ActionEvent apears (not before and not after the OptionDialog).

      import java.awt.*;
      import javax.swing.*;
      import java.awt.event.*;
      import javax.swing.event.*;

      public class Dialog implements FocusListener, ActionListener {
          public static void main(String[] args) {
              JFrame frame = new JFrame("OptionPane in FocusLost");
              JTextField textField = new JTextField("Halilalo");
              textField.addFocusListener(new Dialog());
              JButton button = new JButton("Button");
      button.addActionListener(new Dialog());
      button.setMnemonic('B');
              frame.getContentPane().setLayout(new FlowLayout());
              frame.getContentPane().add(textField);
              frame.getContentPane().add(button);
              frame.pack();
              frame.setVisible(true);
          }

      public void actionPerformed(ActionEvent e) {
      System.out.println("actionPerformed");
      }

          public void focusLost(FocusEvent e) {
      // System.out.println(e);
      System.out.println("focusLost "+e.isTemporary());
              if (!e.isTemporary()) {
      System.out.println("showMessageDialog");
                  JOptionPane.showMessageDialog(null, "Hallo");
              }
          }

          public void focusGained(FocusEvent e) {
      // System.out.println(e);
          }
      }
      (Review ID: 107250)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bchristi Brent Christian
              Reporter:
              bonealsunw Bret O'neal (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: