以下是如何GLJPanel
通过改进它来制作透明的GLCapabilities
:
/** Creates an instance of a transparent GLJPanel. **/
public static final GLJPanel createTransparentPanel() {
/* Instantiate a new set of GLCapabilities based upon the System's default parameters. */
final GLCapabilities lGLCapabilities = new GLCapabilities(GLProfile.getDefault());
/* Define that we don't wish for the background to be opaque. */
lGLCapabilities.setBackgroundOpaque(false);
/* Create a new GLJPanel based on these capabilities. */
final GLJPanel lGLJPanel = new GLJPanel(lGLCapabilities);
/* Disable opacity for the panel. */
lGLJPanel.setOpaque(false);
/* Return the panel. */
return lGLJPanel;
}
然后可以将其添加到透明的JFrame
. 您可以通过调用为您的 JFrame 启用透明度:
.setBackground(new Color(0,0,0,0));