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

Specification for JLayer.setLayerEventMask() should mention that eventDispatch() might not be called

XMLWordPrintable

    • b94
    • generic
    • generic

      Platform: All
      JDK: 7 b70 - PASS
      JDK: 7 b73 - FAIL

      JCK tests expect that when bitmask of supported event type is set to JLayer with method setLayerEventMask()
      events of corresponding type are received by method javax.swing.plaf.LayerUI.eventDispatched(..).
      This is true for JDK b70 but is not always so for b73+.

      Please see the following code sample:
      ------------------------------------------------------------------------------------------------
      import javax.swing.*;
      import javax.swing.plaf.LayerUI;
      import java.awt.*;
      import java.awt.event.ComponentEvent;

      public class Test {

          public static void main(String[] args) throws Exception {
              SwingUtilities.invokeAndWait(new Runnable() {
                  public void run() {
                      JPanel view = new JPanel();
                      JLayer<JPanel> layer = new JLayer<JPanel>( view, new LayerUI<JPanel>() {
                          @Override public void eventDispatched(AWTEvent e, JLayer<? extends JPanel> l) {
                              System.out.println("OK. AWTEvent detected: " + e);
                          }
                      });
                      // uncomment the following lines to make eventDispatched() called in JDK7 b73
                      // JFrame window = new JFrame();
                      // window.add(layer);
                      // window.setVisible(true);
                      layer.setLayerEventMask( AWTEvent.COMPONENT_EVENT_MASK );
                      layer.dispatchEvent(new ComponentEvent(view, ComponentEvent.COMPONENT_RESIZED));

                  }
              });
          }
      }
      ------------------------------------------------------------------------------------------------

      Line
      "OK. AWTEvent detected: java.awt.event.ComponentEvent[COMPONENT_RESIZED (0,0 0x0)] on javax.swing.JPanel[,0,0,0x0,invalid........"
      will be always printed for b70 but for b73+ only with uncommented lines that add JLayer to hierarchy.

            alexp Alexander Potochkin (Inactive)
            dbessono Dmitry Bessonov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: