This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: GLightweightPeer,LightweightPeer,Toolkit allow creation and display of lightweight components
- From: "Scott Gilbertson" <scottg at mantatest dot com>
- To: <java-patches at gcc dot gnu dot org>
- Date: Mon, 2 Dec 2002 12:41:43 -0500
- Subject: Patch: GLightweightPeer,LightweightPeer,Toolkit allow creation and display of lightweight components
These changes allow creation and display of lighweight components by
directly subclassing java.awt.Component and java.awt.Container. It seems a
bit inelegant to make LightweightPeer extend ContainerPeer, but it works
well and doesn't really cost anything. I can't offhand think of a situation
where you'd need to be able to distinguish between a ContainerPeer and a
ComponentPeer by inspecting the class.
Index: libjava/ChangeLog
from Scott Gilbertson <scottg@mantatest.com>
* java/awt/GLightweightPeer.java, java/awt/peer/LightweightPeer.java,
java/awt/Toolkit.java: Implemented lightweight
Component and Container
diff -r -up gcc.patched/libjava/gnu/java/awt/GLightweightPeer.java
gcc/libjava/gnu/java/awt/GLightweightPeer.java
--- gcc.patched/libjava/gnu/java/awt/GLightweightPeer.java 2002-12-02
11:45:18.000000000 -0500
+++ gcc/libjava/gnu/java/awt/GLightweightPeer.java 2002-12-02
12:24:03.000000000 -0500
@@ -49,6 +49,26 @@ public class GLightweightPeer implements
public GLightweightPeer() {}
+ //---------- java.awt.peer.ContainerPeer implementation:
+ private static final Insets BLANK_INSETS = new Insets(0, 0, 0, 0);
+ public Insets getInsets()
+ {
+ return (Insets)BLANK_INSETS.clone();
+ }
+
+ public Insets insets ()
+ {
+ return getInsets ();
+ }
+
+ public void beginValidate()
+ {
+ }
+
+ public void endValidate()
+ {
+ }
+
// -------- java.awt.peer.ComponentPeer implementation:
public int checkImage(Image img, int width, int height, ImageObserver o)
diff -r -up gcc.patched/libjava/java/awt/peer/LightweightPeer.java
gcc/libjava/java/awt/peer/LightweightPeer.java
--- gcc.patched/libjava/java/awt/peer/LightweightPeer.java 2002-12-02
11:45:19.000000000 -0500
+++ gcc/libjava/java/awt/peer/LightweightPeer.java 2002-11-20
12:11:59.000000000 -0500
@@ -38,7 +38,7 @@ exception statement from your version. *
package java.awt.peer;
-public interface LightweightPeer extends ComponentPeer
+public interface LightweightPeer extends ContainerPeer // was
ComponentPeer - changed to allow lightweight Container
{
} // interface LightweightPeer
diff -r -up gcc.patched/libjava/java/awt/Toolkit.java
gcc/libjava/java/awt/Toolkit.java
--- gcc.patched/libjava/java/awt/Toolkit.java 2002-12-02
11:45:19.000000000 -0500
+++ gcc/libjava/java/awt/Toolkit.java 2002-11-20 12:14:02.000000000 -0500
@@ -452,7 +452,7 @@ createCheckboxMenuItem(CheckboxMenuItem
protected LightweightPeer
createComponent(Component target)
{
- return null;
+ return gnu.java.awt.GLightweightPeer.INSTANCE;
}
/*************************************************************************/