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

NullPointerException in DropTarget.addNotify()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1
    • 1.4.0
    • 1.4.0
    • client-libs
    • beta2
    • x86
    • windows_2000
    • Verified

    Description


      DropTarget.addNotify(peer) throws NullPointerException in case of (peer==null). It breaks compatibility of our applications switching to jdk1.4

      Note that our applications use nothing from java.awt.dnd package and the problem appears just for jdk1.4.

      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b64)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b64, mixed mode)

      java.lang.NullPointerException
              at java.awt.dnd.DropTarget.addNotify(DropTarget.java:457)
              at java.awt.Component.addNotify(Component.java:5271)
              at java.awt.Container.addNotify(Container.java:1949)
              at javax.swing.JComponent.addNotify(JComponent.java:4141)
              at java.awt.Container.addNotify(Container.java:1957)
              at javax.swing.JComponent.addNotify(JComponent.java:4141)
              at java.awt.Container.addNotify(Container.java:1957)
              at javax.swing.JComponent.addNotify(JComponent.java:4141)
              at javax.swing.JRootPane.addNotify(JRootPane.java:664)


      -----------------------
      We use imaginary frame for printing of html documents. The frame has no peer to avoid its displaing on screen. This is demo code (it uses other frame for printing document instaed of real printer):


      public class JHFrame extends JFrame {

          public void addNotify() {
              getRootPane().addNotify();
          }

          public void validate() {
              validateTree();
          }

          public static void main(String args[]) {
              try {
                  JEditorPane editor = new JEditorPane("http://java.sun.com");
                  
                  Thread.sleep(1000); // waiting for page download and render
                              
                  JFrame frame = new JHFrame();
                  frame.setContentPane(editor);
                  frame.setBounds(0, 0, 200, 200);
                  frame.setVisible(true);
                  
                  JFrame view = new JFrame("Printing frame");
                  view.setBounds(0, 200, 200, 200);
                  view.setVisible(true);
                  
                  editor.paint(view.getGraphics());
                  
              } catch (Exception e) {
                  e.printStackTrace();
                  System.exit(0);
              }
          }
      }

      This code works on jdk1.3 but not on jdk1.4.

      stepan.marek@czech 2001-05-24

      I've modified Stepan's code slightly because it didn't work in my environment. I've attached the modification. To execute:

      java JHFrame jws.html

      Note: This is probably due to the DnD additions to the JEditorPane since the DnD code never changed.

      roger.brinkley@Eng 2001-05-24

      Update the attachemnts


      roger.brinkley@Eng 2001-05-24

      Attachments

        Activity

          People

            dassunw Das Das (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: