Login  Register

Re: Mac Canvas3D location bug

Posted by Manu on Sep 29, 2013; 9:32pm
URL: https://forum.jogamp.org/Mac-Canvas3D-location-bug-tp4030052p4030143.html

I found how to reproduce the issue I mentioned in my last message. It comes from the organization of the panels in Sweet Home 3D, where the root pane of the frame contains a child root pane.
Here's an example showing the same bug:

import java.awt.GraphicsEnvironment;
import javax.media.j3d.*;
import javax.swing.*;
import com.sun.j3d.utils.universe.SimpleUniverse;

public class Canvas3DPositionTest {
  public static void main(String [] args) {
    // Create a new canvas 3D
    GraphicsConfigTemplate3D gc = new GraphicsConfigTemplate3D();
    Canvas3D canvas = new Canvas3D(GraphicsEnvironment.getLocalGraphicsEnvironment().
        getDefaultScreenDevice().getBestConfiguration(gc));
    new SimpleUniverse(canvas);

    // Build a GUI where the canvas 3D is located at top right of the frame 
    // and can be resized with split panes dividers
    JFrame frame = new JFrame("Canvas3DPositionTest");
    JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, 
        true, new JScrollPane(), canvas);    
    verticalSplitPane.setResizeWeight(0.5);
    JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, 
        true, new JScrollPane(), verticalSplitPane);
    horizontalSplitPane.setResizeWeight(0.5);
    JRootPane intermediateRootPane = new JRootPane();
    intermediateRootPane.setContentPane(horizontalSplitPane);
    frame.add(intermediateRootPane);
    frame.setSize(400, 400);
    frame.setVisible(true);
  }
}

Hope you can fix it...
Emmanuel Puybaret