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

NullPointerException when adding JInternalFrame and JSplitPane to a JDesktopPane

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • client-libs
    • beta
    • x86
    • windows_2000



      Name: stC104175 Date: 07/19/2000


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

      Here's a simplified version of my source that produces the problem. The actual
      UI for my program involves adding multiple panels (one of which is a
      JSplitPane) into a "main" panel that is added to a JDesktopPane. When I add a
      JInternalFrame to the same JDesktopPane, the program terminates with a NPE
      (shown below.)

      ----------------------------------------
      import javax.swing.*;

      public class MyApp
      {
          public static void main(String[] args)
          {
      JFrame frame = new JFrame();

      JDesktopPane desktopPane = new JDesktopPane();
      frame.setContentPane(desktopPane);

      JInternalFrame internalFrame = new JInternalFrame();
      desktopPane.add(internalFrame);
      internalFrame.setVisible(true);

              desktopPane.add(new JSplitPane());
          }
      }
      ----------------------------------

      Here's the result:

      Exception in thread "main" java.lang.NullPointerException: peer
              at sun.awt.windows.WCanvasPeer.create(Native Method)
              at sun.awt.windows.WComponentPeer.<init>(Unknown Source)
              at sun.awt.windows.WCanvasPeer.<init>(Unknown Source)
              at sun.awt.windows.WToolkit.createCanvas(Unknown Source)
              at java.awt.Canvas.addNotify(Unknown Source)
              at java.awt.Container.addNotify(Unknown Source)
              at javax.swing.JComponent.addNotify(Unknown Source)
              at java.awt.Container.addImpl(Unknown Source)
              at javax.swing.JLayeredPane.addImpl(Unknown Source)
              at java.awt.Container.add(Unknown Source)
              at MyApp.main(MyApp.java:16)
      (Review ID: 107345)
      ======================================================================

            rraysunw Richard Ray (Inactive)
            stompkinsunw Sean Tompkins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: