Re: Java 1.6.0 pre12 with JOGL 2.3.1 crashes under OpenSUSE 13.2 with Mesa
Posted by Andreas on Sep 30, 2015; 12:36pm
URL: https://forum.jogamp.org/Java-1-6-0-pre12-with-JOGL-2-3-1-crashes-under-OpenSUSE-13-2-with-Mesa-tp4035401p4035416.html
Hi,
here is a Swing JTabbedPane example. When switching between the Tabs it crashes.
Andreas
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package java3dapplication;
import com.sun.j3d.exp.swing.JCanvas3D;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
/**
*
* @author hauffe
*/
public class Java3DApplication extends JPanel {
public Java3DApplication() {
super(new GridLayout(1, 1));
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("Tab 1", null, new View3D(1), "Does nothing");
tabbedPane.addTab("Tab 2", null, new View3D(2), "Does nothing");
tabbedPane.addTab("Tab 3", null, new View3D(3), "Does nothing");
tabbedPane.addTab("Tab 4", null, new View3D(4), "Does nothing");
//Add the tabbed pane to this panel.
add(tabbedPane);
//The following line enables to use scrolling tabs.
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}
/**
* Create the GUI and show it. For thread safety, this method should be
* invoked from the event dispatch thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("Java3DApplication");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add content to the window.
frame.add(new Java3DApplication(), BorderLayout.CENTER);
//Display the window.
frame.setSize(640,480);
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event dispatch thread:
//creating and showing this application's GUI.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
//Turn off metal's use of bold fonts
UIManager.put("swing.boldMetal", Boolean.FALSE);
createAndShowGUI();
}
});
}
private class View3D extends JPanel {
private final JCanvas3D jCanvas;
private final int num;
public View3D(int num) {
this.num = num;
this.setLayout(new BorderLayout());
jCanvas = new JCanvas3D();
jCanvas.setResizeMode(JCanvas3D.RESIZE_IMMEDIATELY);
jCanvas.setSize(new Dimension(100, 100));
jCanvas.setMinimumSize(new Dimension(100, 100));
add(jCanvas, BorderLayout.CENTER);
createCanvas();
add(jCanvas, BorderLayout.CENTER);
}
private void createCanvas() {
SimpleUniverse simpleUniverse = new SimpleUniverse(jCanvas.getOffscreenCanvas3D());
simpleUniverse.getViewingPlatform().setNominalViewingTransform();
simpleUniverse.getViewer().getView().setSceneAntialiasingEnable(true);
simpleUniverse.getViewer().getView().setFrontClipPolicy(View.VIRTUAL_EYE);
simpleUniverse.getViewer().getView().setFrontClipDistance(-100.0);
simpleUniverse.getViewer().getView().setProjectionPolicy(View.PARALLEL_PROJECTION);
simpleUniverse.getViewer().getView().setDepthBufferFreezeTransparent(false);
BranchGroup rootBranchGroup = new BranchGroup();
TransformGroup rootTransformGroup = new TransformGroup();
rootBranchGroup.addChild(rootTransformGroup);
rootTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
ColorCube colorCube = new ColorCube();
rootTransformGroup.addChild(colorCube);
rootBranchGroup.compile();
simpleUniverse.addBranchGraph(rootBranchGroup);
}
}
}