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

NullPointer when exposing a JInternalFrame with DropTarget

XMLWordPrintable

    • generic
    • generic



      Name: krT82822 Date: 03/06/2000


      6 Mar 2000, eval1127@eng -- may be dupe/releative of # 4218515.

      (see also 4218515, 4109910)

      java version "1.3.0rc1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
      Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)


      We have had NullPointerExceptions from DropTarget's addNotify()
      method, when a JInternalFrame containing a DropTarget is made visible
      by setVisible(true). This bug is probably part of the new
      visibility model for JInternalFrames in 1.3 beta and 1.3RC1:


      Exception in thread "main" java.lang.NullPointerException
              at java.awt.dnd.DropTarget.addNotify(DropTarget.java:431)
              at java.awt.Component.addNotify(Component.java:4046)
              at java.awt.Container.addNotify(Container.java:1548)
              at javax.swing.JComponent.addNotify(JComponent.java:4013)
              at java.awt.Container.addNotify(Container.java:1555)
              at javax.swing.JComponent.addNotify(JComponent.java:4013)
              at java.awt.Container.addNotify(Container.java:1555)
              at javax.swing.JComponent.addNotify(JComponent.java:4013)
              at java.awt.Container.addNotify(Container.java:1555)
              at javax.swing.JComponent.addNotify(JComponent.java:4013)
              at java.awt.Container.addNotify(Container.java:1555)
              at javax.swing.JComponent.addNotify(JComponent.java:4013)
              at java.awt.Container.addNotify(Container.java:1555)
              at javax.swing.JComponent.addNotify(JComponent.java:4013)
              at javax.swing.JRootPane.addNotify(JRootPane.java:483)
              at java.awt.Container.addNotify(Container.java:1555)
              at javax.swing.JComponent.addNotify(JComponent.java:4013)
              at java.awt.Container.addNotify(Container.java:1555)
              at javax.swing.JComponent.addNotify(JComponent.java:4013)
              at javax.swing.JInternalFrame.show(JInternalFrame.java:1442)
              at java.awt.Component.show(Component.java:946)
              at java.awt.Component.setVisible(Component.java:903)
              at javax.swing.JComponent.setVisible(JComponent.java:1885)
              at icat.ictt.chat.ChatWindow.init(icat/ictt/chat/ChatWindow.java:408)
              at icat.ictt.chat.ChatWindow.<init>(icat/ictt/chat/ChatWindow.java:437)
              at icat.ictt.chat.ChatWindow.main(icat/ictt/chat/ChatWindow.java:462)



      Here is the source, from DropTarget.java. The code at (1) is walking up
      the tree hierarchy, looking for the Peer of the first heavyweight
      component. Note that it does not check for a "not found," which
      can happen for JInternalFrame. Also note that (2) is not considering
      the possibility of a null, either.


          public void addNotify(ComponentPeer peer) {
      /*
      * FIX THIS FOR BETA4
      */

      // java.security.AccessController.checkPermission(new
      AWTPermission("setDTarget"));
      if (peer == componentPeer) return;

      componentPeer = peer;

      (1)--> for (Component c = component; peer instanceof LightweightPeer; c =
      c.getParent())
      peer = c.getPeer();

      try {
      (2)--> ((DropTargetPeer)(nativePeer = peer)).addDropTarget(this);
      } catch (ClassCastException cce) {
      nativePeer = null;
      // throw new InvalidDnDOperationException("No Native Peer support");
      }
          }
      (Review ID: 102116)
      ======================================================================

            rbrinkle Roger Brinkley (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: