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

Component.processFocusEvent is not called by event dispatch thread

    XMLWordPrintable

Details

    • b28
    • sparc
    • solaris_2.6

    Description

      Name: dsR10051 Date: 10/17/2000



      The method
      protected void java.awt.Component.processFocusEvent(FocusEvent e)
      is not called by event dispatch thread even if a FocusListener
      object is registered via addFocusListener
      (See JavaDoc for Component.processFocusEvent).

      Here is a minimized test:
      import java.awt.*;
      import java.awt.event.*;

      public class ComponentTest4 {
          public static void main (String[] args) {
              EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
              ChildComponent chcomponent = new ChildComponent();
              FocusEvent e = new FocusEvent(chcomponent, FocusEvent.FOCUS_LOST);
              DummyFocusListener cl = new DummyFocusListener();
              chcomponent.addFocusListener(cl);

              eq.postEvent(e);
              synchronized (chcomponent) {
                  while(!chcomponent.focusEventProcessed) {
                      try {
                          System.out.println("Waiting");
                          System.out.flush();

                          chcomponent.wait();

                          System.out.println("Done");
                          System.out.flush();
                      } catch (InterruptedException ie) {
                          ie.printStackTrace();
                      }
                  }
              }
              System.exit(0);
          }
      }

      class ChildComponent extends Component {
          public ChildComponent() {
              super();
          }

          boolean focusEventProcessed = false;
          public synchronized void processFocusEvent(FocusEvent e) {
              focusEventProcessed = true;
              System.out.println("processFocusEvent called");
              System.out.flush();
              super.processFocusEvent(e);
              System.out.println("processFocusEvent done");
              System.out.flush();
              notifyAll();
          }
      }

      class DummyFocusListener extends FocusAdapter {
      }

      --- Output ---
      %/net/sword/export3/JDK1.4.0beta-b36/solaris/bin/java -version
      java version "1.4.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b36)
      Java HotSpot(TM) Client VM (build 1.4beta-B36, mixed mode)
      %/net/sword/export3/JDK1.4.0beta-b36/solaris/bin/java ComponentTest4
      Waiting
      ^C
      %

      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              son Oleg Sukhodolsky (Inactive)
              sdasunw Sda Sda (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: