Reputation: 111
public class Activator implements BundleActivator {
TestFrame testFrame = new TestFrame();
public static JPanel graphPanel;
public void start(BundleContext context) throws Exception {
graphPanel = cartesianGraphs.getGraphPanel();
testFrame.getPanel1().add(graphPanel);
testFrame.setVisible(true);
}
}
public class TestFrame extends JFrame {
private static final long serialVersionUID = 1L;
private library kutuphane = null;
private JPanel contentPane;
private JTabbedPane tabbedPane;
private JPanel panel1;
private JButton btn;
public TestFrame() {
initComponents();
}
private void initComponents() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 800, 600);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
contentPane.add(getTabbedPane(), BorderLayout.CENTER);
contentPane.add(getBtn(), BorderLayout.NORTH);
}
public JPanel getPanel1() {
if (panel1 == null) {
panel1 = new JPanel();
panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS));
}
return panel1;
}
private JButton getBtn() {
if (btn == null) {
btn = new JButton("Remove All and Add");
btnTabSil.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
TestFrame.this.getPanel1().removeAll();
Activator.graphPanel.revalidate();
// where it throws the exception is below
TestFrame.this.getPanel1().add(Activator.graphPanel);
TestFrame.this.revalidate();
TestFrame.this.repaint();
TestFrame.this.setVisible(true);
}
});
}
return btn;
}
}
In the activator class above I add (JPanel )graphpanel into (JPannel) testFrame.getPanel1() Then with a button in the testFrame class I used removeAll() method and add the static graphPannel again but I got the error below.
When I debug it I see that GLcanvas looses the peer. I couldnt find a solution.
Exception in thread "Thread-3" java.lang.RuntimeException: javax.media.opengl.GLException: Unable to create temp OpenGL context for device context 0xffffffffde01148b at jogamp.common.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58) at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103) at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:205) at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172) at javax.media.opengl.Threading.invoke(Threading.java:191) at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:449) at grafik.view.grafik.Gcontroller.draw(Gcontroller.java:169) at grafik.model.data.Dcontroller.drawAll(Dcontroller.java:272) at grafik.view.Wcontroller.GdataClean(Wcontroller.java:261) at grafik.view.WThread.run(WThread.java:57) Caused by: javax.media.opengl.GLException: Unable to create temp OpenGL context for device context 0xffffffffde01148b at jogamp.opengl.windows.wgl.WindowsWGLContext.createImpl(WindowsWGLContext.java:306) at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:572) at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:485) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:645) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:594) at javax.media.opengl.awt.GLCanvas$8.run(GLCanvas.java:996) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$300(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
Upvotes: 1
Views: 837
Reputation: 4125
Please switch to JOGL 2.3.1. Then, replace "javax.media" by "com.jogamp" to avoid any compile error.
When you remove the AWT GLCanvas from its parent container, it loses its peer and its OpenGL context is destroyed. This is something that you can't avoid when using this kind of canvas. Switch to NEWT if this isn't the desired behavior.
The creation of another context might fail in some particular cases on some hardware. If you still get the same stack trace with the latest version of JOGL, please fill a bug report: http://jogamp.org/wiki/index.php/Jogl_FAQ#Bugreports_.26_Testing
Upvotes: 1