This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gui][PATCH] cache preferred dimensions in Applet


Hello,

This patch changes Applet to cache the dimensions set in its stub.

I committed this to java-gui-branch.

Tom

2004-03-14  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* java/applet/Applet.java (dimensions): New field.
	(getDimensions): New method.
	(getPreferredSize): Call getDimensions.
	(getMinimumSize): Likewise.


Index: java/applet/Applet.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/applet/Applet.java,v
retrieving revision 1.3.36.1
diff -u -r1.3.36.1 Applet.java
--- java/applet/Applet.java	13 Mar 2004 19:44:26 -0000	1.3.36.1
+++ java/applet/Applet.java	14 Mar 2004 19:25:54 -0000
@@ -78,6 +78,11 @@
   private transient AppletStub stub;
 
   /**
+   * The dimensions passed to this applet through its HTML tag.
+   */
+  private transient Dimension dimensions;
+
+  /**
    * The accessibility context for this applet.
    *
    * @serial the accessibleContext for this
@@ -457,6 +462,19 @@
     s.defaultReadObject();
   }
 
+  private Dimension getDimensions ()
+  {
+    if (dimensions == null)
+      {
+	int width = Integer.parseInt(stub.getParameter("width"));
+	int height = Integer.parseInt(stub.getParameter("height"));
+
+	dimensions = new Dimension(width, height);
+      }
+
+    return dimensions;
+  }
+
   /**
    * Returns an instance of {@link Dimension} representing the
    * applet's width and height parameters.
@@ -465,10 +483,7 @@
    */
   public Dimension getPreferredSize()
   {
-    int width = Integer.parseInt(stub.getParameter("width"));
-    int height = Integer.parseInt(stub.getParameter("height"));
-
-    return new Dimension(width, height);
+    return getDimensions ();
   }
 
   /**
@@ -479,10 +494,7 @@
    */
   public Dimension getMinimumSize()
   {
-    int width = Integer.parseInt(stub.getParameter("width"));
-    int height = Integer.parseInt(stub.getParameter("height"));
-
-    return new Dimension(width, height);
+    return getDimensions ();
   }
 
   /**



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]