diff options
author | David Gilbert <david.gilbert@object-refinery.com> | 2006-03-13 21:36:30 +0000 |
---|---|---|
committer | David Gilbert <david.gilbert@object-refinery.com> | 2006-03-13 21:36:30 +0000 |
commit | 6d5ea1f330df92665face8ff6f35c6e7dcb4b537 (patch) | |
tree | 95c3764f34830fd87770800383a60d7a401aea09 | |
parent | 2506eeda6a184c05758d6f29dc88f801ba5cdf1e (diff) | |
download | classpath-6d5ea1f330df92665face8ff6f35c6e7dcb4b537.tar.gz |
2006-03-13 David Gilbert <david.gilbert@object-refinery.com>
* javax/swing/SwingUtilities.java
(calculateInnerArea): handle null component, and replace
getLocalBounds() with getBounds(Rectangle) to avoid unnecessary object
creation.
----------------------------------------------------------------------
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | javax/swing/SwingUtilities.java | 26 |
2 files changed, 20 insertions, 13 deletions
@@ -1,3 +1,10 @@ +2006-03-13 David Gilbert <david.gilbert@object-refinery.com> + + * javax/swing/SwingUtilities.java + (calculateInnerArea): handle null component, and replace + getLocalBounds() with getBounds(Rectangle) to avoid unnecessary object + creation. + 2006-03-13 Roman Kennke <kennke@aicas.com> * javax/swing/JColorChooser.java diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java index c5b80f613..b472342ce 100644 --- a/javax/swing/SwingUtilities.java +++ b/javax/swing/SwingUtilities.java @@ -1,5 +1,5 @@ /* SwingUtilities.java -- - Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -91,23 +91,23 @@ public class SwingUtilities * of the <em>component's</em> coordinate system, where (0,0) is the * upper left corner of the component's bounds. * - * @param c The component to measure the bounds of - * @param r A Rectangle to store the return value in, or - * <code>null</code> + * @param c the component to measure the bounds of (if <code>null</code>, + * this method returns <code>null</code>). + * @param r a carrier to store the return value in (if <code>null</code>, a + * new <code>Rectangle</code> instance is created). * - * @return The calculated area inside the component and its border - * insets + * @return The calculated area inside the component and its border insets. */ public static Rectangle calculateInnerArea(JComponent c, Rectangle r) { - Rectangle b = getLocalBounds(c); - if (r == null) - r = new Rectangle(); + if (c == null) + return null; + r = c.getBounds(r); Insets i = c.getInsets(); - r.x = b.x + i.left; - r.width = b.width - i.left - i.right; - r.y = b.y + i.top; - r.height = b.height - i.top - i.bottom; + r.x = i.left; + r.width = r.width - i.left - i.right; + r.y = i.top; + r.height = r.height - i.top - i.bottom; return r; } |