summaryrefslogtreecommitdiffstats
path: root/src/demos/jgears/JGears.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/jgears/JGears.java')
-rw-r--r--src/demos/jgears/JGears.java31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/demos/jgears/JGears.java b/src/demos/jgears/JGears.java
index ee0690c..59e6c79 100644
--- a/src/demos/jgears/JGears.java
+++ b/src/demos/jgears/JGears.java
@@ -2,6 +2,7 @@ package demos.jgears;
import java.awt.*;
import java.awt.event.*;
+import javax.swing.*;
import net.java.games.jogl.*;
@@ -14,11 +15,33 @@ import net.java.games.jogl.*;
public class JGears {
public static void main(String[] args) {
- Frame frame = new Frame("Gear Demo");
- GLJPanel drawable = GLDrawableFactory.getFactory().createGLJPanel(new GLCapabilities());
-
+ JFrame frame = new JFrame("Gear Demo");
+ frame.getContentPane().setLayout(new BorderLayout());
+ GLCapabilities caps = new GLCapabilities();
+ caps.setAlphaBits(8);
+ final GLJPanel drawable = GLDrawableFactory.getFactory().createGLJPanel(caps);
+ drawable.setOpaque(false);
drawable.addGLEventListener(new GearRenderer());
- frame.add(drawable);
+
+ JPanel gradientPanel = new JPanel() {
+ public void paintComponent(Graphics g) {
+ ((Graphics2D) g).setPaint(new GradientPaint(0, 0, Color.WHITE,
+ getWidth(), getHeight(), Color.DARK_GRAY));
+ g.fillRect(0, 0, getWidth(), getHeight());
+ }
+ };
+ gradientPanel.setLayout(new BorderLayout());
+ frame.getContentPane().add(gradientPanel, BorderLayout.CENTER);
+ gradientPanel.add(drawable, BorderLayout.CENTER);
+
+ final JCheckBox checkBox = new JCheckBox("Transparent", true);
+ checkBox.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ drawable.setOpaque(!checkBox.isSelected());
+ }
+ });
+ frame.getContentPane().add(checkBox, BorderLayout.SOUTH);
+
frame.setSize(300, 300);
final Animator animator = new Animator(drawable);
frame.addWindowListener(new WindowAdapter() {