如何在Java Swing中添加Jogl面板 [英] How to add jogl panel in java swing

查看:48
本文介绍了如何在Java Swing中添加Jogl面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个Java swing应用程序,该应用程序的一侧具有按钮,而另一侧具有openGL视图(jogl),该视图根据所按下的按钮显示内容.我的问题是,当我将JFrame分为2个部分时,第一个将按钮做得很好,但是我不知道如何在另一侧添加OpenGL/jogl面板.我有一个定义我的jogl应用程序的类,但是我应该如何将其添加到JFrame中呢?我尝试了扩展面板GLJPanel,Frame(我不认为应该从一开始就可以使用),但是没有运气将jogl类添加到我的框架中.任何帮助或建议,表示赞赏!

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. 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. I have a class that defines my jogl application, but how am I supposed to add it to a 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. Any help or suggestions are appreciated!

推荐答案

GLJPanel扩展了JComponent,因此可以将其添加到挥杆布局中.例如,您可以使用非常简单的 BorderLayout 进行显示一些按钮.

GLJPanel extends JComponent so it can be added to swing layouts. For example you can use a very simple BorderLayout to show it next to some buttons.

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.

这篇关于如何在Java Swing中添加Jogl面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆