简体   繁体   English

如何在Java Swing中添加Jogl面板

[英]How to add jogl panel in java swing

I am trying to write a java swing application that has buttons on one side and an openGL view (jogl)on the other side that displays things depending on what button is pressed. 我正在尝试编写一个Java swing应用程序,该应用程序的一侧具有按钮,而另一侧具有openGL视图(jogl),根据所按下的按钮显示内容。 My problem is that when I split the JFrame into 2 sections, the first one takes the buttons fine, but I can't figure out how to add the OpenGL/jogl panel to the other side. 我的问题是,当我将JFrame分为2个部分时,第一个将按钮做得很好,但是我不知道如何在另一侧添加OpenGL / jogl面板。 I have a class that defines my jogl application, but how am I supposed to add it to a JFrame? 我有一个定义我的jogl应用程序的类,但是我应该如何将其添加到JFrame中呢? I tried extending panel, GLJPanel, Frame (I didn't think that one would work to begin with), but have had no luck adding the jogl class to my frame. 我尝试了扩展面板GLJPanel,Frame(我不认为应该从一开始就可以使用),但是没有运气将jogl类添加到我的框架中。 Any help or suggestions are appreciated! 任何帮助或建议,不胜感激!

GLJPanel extends JComponent so it can be added to swing layouts. GLJPanel扩展了JComponent因此可以将其添加到秋千布局中。 For example you can use a very simple BorderLayout to show it next to some buttons. 例如,您可以使用非常简单的BorderLayout将其显示在某些按钮旁边。

Container pane = yourFrame.getContentPane();
JPanel panelWithButtons = new JPanel(); 

// add your buttons to panelWithButtons here

// add the panel with the buttons to the layout
pane.add(panelWithButtons , BorderLayout.LINE_START);

// create the jogl panel and add it to the layout
GLJPanel glPanel = ... 
pane.add(glPanel , BorderLayout.CENTER);

Here you can find more information on layout managers. 在这里,您可以找到有关布局管理器的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM