java3d
  1. java3d
  2. JAVA3D-397

JCanvas3D crashes when using non-null layout managers; setting size and position manually when using null layout causes runtime error

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.5.0
    • Fix Version/s: 1.6.0
    • Component/s: j3d-core
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

    • Issuezilla Id:
      397

      Description

      When setting a layout manager or using the default BorderLayout used by a JFrame
      the JCanvas3D crashes. This seems to be independent of the ResizeMode and
      ResizeValidationDelay. Obviously the positioning and resizing operations handled
      by the manager lead to the crash. Running the following code with a Canvas3D
      wirks perfectly.

      Some test code:

      public class AnimationMainFrame extends JFrame{

      //get graphics device to use
      GraphicsDevice device =
      GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();

      //create canvas
      JCanvas3D canvas = new JCanvas3D(device);

      public AnimationMainFrame()

      { //initialize mainframe setLayout(new BorderLayout()); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(512,512); //setup and add canvas to main frame canvas.setBackground(Color.BLACK); //for test purpose add(canvas); //make JFrame visible setVisible(true); }

      As stated above this works fine with the heavyweight pendant. The second problem
      I figured occurs when you take over the work of the manager by setting the null
      layout. When setting size and position of the component a NullPointerException
      is put out. See the whole error below:

      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at com.sun.j3d.exp.swing.JCanvas3D.paintComponent(JCanvas3D.java:394)
      at javax.swing.JComponent.paint(JComponent.java:1022)
      at javax.swing.JComponent.paintChildren(JComponent.java:859)
      at javax.swing.JComponent.paint(JComponent.java:1031)
      at javax.swing.JComponent.paintChildren(JComponent.java:859)
      at javax.swing.JComponent.paint(JComponent.java:1031)
      at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)
      at javax.swing.JComponent.paintChildren(JComponent.java:859)
      at javax.swing.JComponent.paintToOffscreen(JComponent.java:5111)
      at
      javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)
      at javax.swing.RepaintManager.paint(RepaintManager.java:1132)
      at javax.swing.JComponent.paint(JComponent.java:1008)
      at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
      at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
      at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
      at java.awt.Container.paint(Container.java:1797)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:738)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:683)
      at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:663)
      at
      javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
      at
      java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
      at
      java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

      This error is caused by the following code in the altered constructor:

      public AnimationMainFrame()

      { //initialize mainframe setLayout(null); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(512,512); //setup and add canvas to main frame canvas.setLocation(64,64); //added since layout is null canvas.setSize(128,128); //added since layout is null canvas.setBackground(Color.BLACK); //for test purpose add(canvas); //make JFrame visible setVisible(true); }

      The weird thing is that one is able to continue via the debugger and allow the
      frame and canvas to be drawn. Immediately after this is done the canvas crashes.

      This was tested with the following configuration:

      • Windows XP x64
      • JDK 1.6.0 RC x64
      • Java3D 1.5.0 beta2 x64

        Activity

        Hide
        stylertim added a comment -

        Just stumbled over a workaround for the null layout problem. Adding the
        corresponding offScrennCanvas3D to the a SimpleUniverse AFTER the JCanvas3D has
        been added to parent frame bypasses the error described above.

        SimpleUniverse universe;
        [..]
        add(canvas);
        universe new SimpleUniverse(canvas.getOffscreenCanvas3D());

        Adding it BEFORE results in the same error stated above!

        Show
        stylertim added a comment - Just stumbled over a workaround for the null layout problem. Adding the corresponding offScrennCanvas3D to the a SimpleUniverse AFTER the JCanvas3D has been added to parent frame bypasses the error described above. SimpleUniverse universe; [..] add(canvas); universe new SimpleUniverse(canvas.getOffscreenCanvas3D()); Adding it BEFORE results in the same error stated above!
        Hide
        kcr added a comment -

        Assign to pepe for evaluation for 1.5.1.

        Show
        kcr added a comment - Assign to pepe for evaluation for 1.5.1.
        Hide
        kcr added a comment -

        Set target to next release.

        Show
        kcr added a comment - Set target to next release.

          People

          • Assignee:
            pepe
            Reporter:
            stylertim
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: