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

ClassCastException in Component.getMousePosition() in Browser under MacOS

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 7
    • client-libs
    • None

      FULL PRODUCT VERSION :
      java version " 1.7.0_15 "
      Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
      Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin dimitrys-mac-mini.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64


      A DESCRIPTION OF THE PROBLEM :
      calls of ComponentgetMousePosition() for applets running in any browser like firefox are interrupted by ClassCast Exception with trace

      java.lang.ClassCastException: sun.lwawt.macosx.CPlatformEmbeddedFrame cannot be cast to sun.lwawt.macosx.CPlatformWindow
      at sun.lwawt.macosx.CMouseInfoPeer.isWindowUnderMouse(CMouseInfoPeer.java:45)
      at java.awt.Component.findUnderMouseInWindow(Component.java:1325)
      at java.awt.Component.getMousePosition(Component.java:1377)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Open the following html page embedding the applet in a Web Browser using java plug-in and click on button " click me "
       
      <html><body>
      <object classid= " java:JAppletExample.class "
          codetype= " application/java-vm " width= " 800 " height= " 200 " >
      </object>
      </body></html>

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      button text should be changed to " clicked " ,
      no exception should be thrown
      ACTUAL -
      ClassCastException is thrown,
      the text on the button is " sun.lwawt.macosx.CPlatformEmbeddedFrame cannot be cast to sun.lwawt.macosx.CPlatformWindow " ,
      Exception trace appears on the java console

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.ClassCastException: sun.lwawt.macosx.CPlatformEmbeddedFrame cannot be cast to sun.lwawt.macosx.CPlatformWindow
      at sun.lwawt.macosx.CMouseInfoPeer.isWindowUnderMouse(CMouseInfoPeer.java:45)
      at java.awt.Component.findUnderMouseInWindow(Component.java:1325)
      at java.awt.Component.getMousePosition(Component.java:1377)
      at JAppletExample$1.actionPerformed(JAppletExample.java:18)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
      at java.awt.Component.processMouseEvent(Component.java:6505)
      at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
      at java.awt.Component.processEvent(Component.java:6270)
      at java.awt.Container.processEvent(Container.java:2229)
      at java.awt.Component.dispatchEventImpl(Component.java:4861)
      at java.awt.Container.dispatchEventImpl(Container.java:2287)
      at java.awt.Component.dispatchEvent(Component.java:4687)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
      at java.awt.Container.dispatchEventImpl(Container.java:2273)
      at java.awt.Component.dispatchEvent(Component.java:4687)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
      at java.awt.EventQueue.access$200(EventQueue.java:103)
      at java.awt.EventQueue$3.run(EventQueue.java:688)
      at java.awt.EventQueue$3.run(EventQueue.java:686)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
      at java.awt.EventQueue$4.run(EventQueue.java:702)
      at java.awt.EventQueue$4.run(EventQueue.java:700)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // java
      import java.awt.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      import javax.swing.*;

      public class JAppletExample extends JApplet {
        public void init() {
          Container content = getContentPane();
          content.setBackground(Color.white);
          content.setLayout(new FlowLayout());
          final JButton button = new JButton( " Click me " );
          button.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
      try {
                  button.getMousePosition();
                  button.setText( " Clicked " );
                  }
                  catch (Exception e1) {
                 button.setText(e1.getMessage());
                 e1.printStackTrace();
                  }
      }
      });
      content.add(button);
        }
      }
      ---------- END SOURCE ----------

            pchelko Petr Pchelko (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: