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;
}
}
在上面的激活器类中,我将 (JPanel) graphpanel添加到 (JPannel) testFrame.getPanel1()然后使用 testFrame 类中的一个按钮,我使用removeAll()方法并再次添加静态 graphPannel,但出现以下错误。
当我调试它时,我看到 GLcanvas 失去了 peer。我找不到解决方案。
线程“Thread-3”中的异常 java.lang.RuntimeException:javax.media.opengl.GLException:无法在 jogamp.common.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58) 处为设备上下文 0xffffffffde01148b 创建临时 OpenGL 上下文jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103) 在 jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:205) 在 javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172) 在 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 ) 在 grafik.view 的 grafik.view.Wcontroller.GdataClean(Wcontroller.java:261) 的 grafik.model.data.Dcontroller.drawAll(Dcontroller.java:272)。WThread.run(WThread.java:57) 原因:javax.media.opengl.GLException:无法在 jogamp.opengl.windows.wgl.WindowsWGLContext.createImpl(WindowsWGLContext.java:306) 为设备上下文 0xffffffffde01148b 创建临时 OpenGL 上下文在 jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:572) 在 jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:645) 在 jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:485)。 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。在 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.run(Unknown Source)。 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(未知源)在 java.awt.EventDispatchThread.pumpEvents(未知源)在 java.awt.EventDispatchThread.run(未知源)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)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)java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) 的 pumpEvents(Unknown Source)java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) 的 pumpEvents(Unknown Source)