在lwjgl窗口中呈现javax.swing.JButton [英] Rendering javax.swing.JButton in a lwjgl window
问题描述
是否可以在lwjgl窗口(使用openGL)中呈现javax.swing.JButton和其他swing元素?如果没有,你可以在lwjgl的游戏GUI中建议什么?
Is it possible to render a javax.swing.JButton and other swing elements in a lwjgl window (with openGL)? If not, what can you recomend for in game GUI in lwjgl?
注意:我尝试过Nifty-GUI和TWL,但我不喜欢XML部分,并且文档很差......
推荐答案
添加 javax.swing.JButton
到一个 java.awt.Canvas
用于 显示
可能会受到渲染工件的影响。相反,请尝试以下替代方法之一:
Adding a javax.swing.JButton
to a java.awt.Canvas
used for Display
may be subject to rendering artifacts. Instead, try one of the following alternatives:
Add the button to a
JPanel
, as shown here. Put yourDisplay
in aCanvas
, as shown here. Put both in a suitable layout, e.g.
add(canvas, BorderLayout.CENTER;
add(panel, BorderLayout.SOUTH);
控制显示
在无模式对话框中使用组件,此处。
Control your Display
using components in a modeless dialog, illustrated here.
这篇关于在lwjgl窗口中呈现javax.swing.JButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!