diff options
author | Christopher Oliver <[email protected]> | 2008-10-16 16:02:53 +0000 |
---|---|---|
committer | Christopher Oliver <[email protected]> | 2008-10-16 16:02:53 +0000 |
commit | be3647b14ec597c655d82f673ccf6164c4243078 (patch) | |
tree | 3f40f5f2195d4fcaef9a8c67c845300651cda0d7 /src/classes/com | |
parent | e55ba56033cb9193d019cda701673430c919824c (diff) |
using alternate hack for window transparency
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1774 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com')
-rw-r--r-- | src/classes/com/sun/javafx/newt/awt/AWTWindow.java | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/classes/com/sun/javafx/newt/awt/AWTWindow.java b/src/classes/com/sun/javafx/newt/awt/AWTWindow.java index 0f5b1df6f..6ec1622ac 100644 --- a/src/classes/com/sun/javafx/newt/awt/AWTWindow.java +++ b/src/classes/com/sun/javafx/newt/awt/AWTWindow.java @@ -40,9 +40,10 @@ import java.awt.EventQueue; import java.awt.Frame; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; import java.awt.event.*; import java.util.*; - import com.sun.javafx.newt.Window; /** An implementation of the Newt Window class built using the @@ -50,7 +51,31 @@ import com.sun.javafx.newt.Window; supporting Java SE. */ public class AWTWindow extends Window { - private javax.swing.JFrame frame; + + static void setWindowAlpha(java.awt.Window w, float alpha) { + // hack for macosx only + Object peer = w.getPeer(); + if (peer == null) { + return; + } + Class peerClass = peer.getClass(); + + //noinspection EmptyCatchBlock + try { + Class nativeClass = Class.forName("apple.awt.CWindow"); + if (nativeClass.isAssignableFrom(peerClass)) { + Method setAlpha = nativeClass.getMethod("setAlpha", + new Class[] {float.class}); + setAlpha.invoke(peer, new Object[] { new Double(Math.max(0.0f, Math.min(alpha, 1.0f)))}); + } + } catch (ClassNotFoundException e) { + } catch (NoSuchMethodException e) { + } catch (IllegalAccessException e) { + } catch (InvocationTargetException e) { + } + } + + private Frame frame; private Canvas canvas; private LinkedList/*<AWTEventWrapper>*/ events = new LinkedList(); private boolean gotDisplaySize; @@ -71,21 +96,19 @@ public class AWTWindow extends Window { protected void createNative() { runOnEDT(new Runnable() { public void run() { - frame = new javax.swing.JFrame(getTitle()); + frame = new Frame(getTitle()); frame.setUndecorated(isUndecorated()); if (isUndecorated()) { - frame.setBackground(new java.awt.Color(0, 0, 0, 0)); - frame.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE); + setWindowAlpha(frame, 0); } frame.setLayout(new BorderLayout()); canvas = new Canvas(); - canvas.setBackground(new java.awt.Color(0, 0, 0, 0)); Listener listener = new Listener(); canvas.addMouseListener(listener); canvas.addMouseMotionListener(listener); canvas.addKeyListener(listener); canvas.addComponentListener(listener); - frame.getContentPane().add(canvas);//add(canvas, BorderLayout.CENTER); + frame.add(canvas, BorderLayout.CENTER); frame.setSize(width, height); frame.setLocation(x, y); frame.addComponentListener(new MoveListener()); |