aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2007-05-05 18:35:07 +0000
committerKenneth Russel <[email protected]>2007-05-05 18:35:07 +0000
commit1204b255cd54a8dd2ca3e2a76d144c25046c5ca5 (patch)
treed7297e9ec1b993892610073b4fe56acdcff5f7d2
parent64b9f2988dbfc0f7e54359f7da79c151091bf245 (diff)
Changes to make GLCanvas and GLJPanel work better in NetBeans GUI
builder based on suggestions from Josh Marinacci git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1234 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r--src/classes/javax/media/opengl/GLCanvas.java25
-rw-r--r--src/classes/javax/media/opengl/GLJPanel.java21
2 files changed, 46 insertions, 0 deletions
diff --git a/src/classes/javax/media/opengl/GLCanvas.java b/src/classes/javax/media/opengl/GLCanvas.java
index dc25d3844..4c39f912e 100644
--- a/src/classes/javax/media/opengl/GLCanvas.java
+++ b/src/classes/javax/media/opengl/GLCanvas.java
@@ -40,10 +40,14 @@
package javax.media.opengl;
import java.awt.Canvas;
+import java.awt.Color;
import java.awt.EventQueue;
+import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
+import java.awt.geom.*;
+import java.beans.*;
import java.lang.reflect.*;
import java.security.*;
import com.sun.opengl.impl.*;
@@ -139,6 +143,27 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
<B>Overrides:</B>
<DL><DD><CODE>paint</CODE> in class <CODE>java.awt.Component</CODE></DD></DL> */
public void paint(Graphics g) {
+ if (Beans.isDesignTime()) {
+ // Make GLCanvas behave better in NetBeans GUI builder
+ g.setColor(Color.BLACK);
+ g.fillRect(0, 0, getWidth(), getHeight());
+ FontMetrics fm = g.getFontMetrics();
+ String name = getName();
+ if (name == null) {
+ name = getClass().getName();
+ int idx = name.lastIndexOf('.');
+ if (idx >= 0) {
+ name = name.substring(idx + 1);
+ }
+ }
+ Rectangle2D bounds = fm.getStringBounds(name, g);
+ g.setColor(Color.WHITE);
+ g.drawString(name,
+ (int) ((getWidth() - bounds.getWidth()) / 2),
+ (int) ((getHeight() + bounds.getHeight()) / 2));
+ return;
+ }
+
display();
}
diff --git a/src/classes/javax/media/opengl/GLJPanel.java b/src/classes/javax/media/opengl/GLJPanel.java
index 180ae2111..e6c96c10d 100644
--- a/src/classes/javax/media/opengl/GLJPanel.java
+++ b/src/classes/javax/media/opengl/GLJPanel.java
@@ -463,6 +463,27 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
<B>Overrides:</B>
<DL><DD><CODE>paintComponent</CODE> in class <CODE>javax.swing.JComponent</CODE></DD></DL> */
protected void paintComponent(final Graphics g) {
+ if (Beans.isDesignTime()) {
+ // Make GLJPanel behave better in NetBeans GUI builder
+ g.setColor(Color.BLACK);
+ g.fillRect(0, 0, getWidth(), getHeight());
+ FontMetrics fm = g.getFontMetrics();
+ String name = getName();
+ if (name == null) {
+ name = getClass().getName();
+ int idx = name.lastIndexOf('.');
+ if (idx >= 0) {
+ name = name.substring(idx + 1);
+ }
+ }
+ Rectangle2D bounds = fm.getStringBounds(name, g);
+ g.setColor(Color.WHITE);
+ g.drawString(name,
+ (int) ((getWidth() - bounds.getWidth()) / 2),
+ (int) ((getHeight() + bounds.getHeight()) / 2));
+ return;
+ }
+
if (shouldInitialize) {
initialize();
}