Re: Mac Canvas3D location bug
Posted by
Manu on
Oct 07, 2013; 2:26pm
URL: https://forum.jogamp.org/Mac-Canvas3D-location-bug-tp4030052p4030184.html
Sorry, I spoke a little too fast about applets. Moving a 3D canvas in an applet doesn't work all the time.
When you try to move horizontally the canvas 3D with the splitter of the following example, its location isn't always correct.
import java.awt.GraphicsEnvironment;
import javax.media.j3d.*;
import javax.swing.*;
import com.sun.j3d.utils.universe.SimpleUniverse;
public class Canvas3DPositionTest extends JApplet {
public void init() {
// 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 bottom right of the frame
// and can be resized with split panes dividers
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);
add(intermediateRootPane);
}
}
Be sure to test under Java 6 and 7 because the applet doesn't behave the same in a browser.
Emmanuel Puybaret