This patch (committed) removes a TODO that I left in the getThumbSize() method last
time I worked on this class. I tested Sun's implementation and found that this
method DOES return a new instance every time it is called even though the size
returned is constant. That could be because Dimension instances can be modified
directly, so you can't (safely) define a constant Dimension instance to return every
time:
2006-03-27 David Gilbert <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicSliderUI.java
(getThumbSize): Removed TODO and updated API docs.
Regards,
Dave
Index: javax/swing/plaf/basic/BasicSliderUI.java
===================================================================
RCS file:
/sources/classpath/classpath/javax/swing/plaf/basic/BasicSliderUI.java,v
retrieving revision 1.24
diff -u -r1.24 BasicSliderUI.java
--- javax/swing/plaf/basic/BasicSliderUI.java 27 Mar 2006 14:53:06 -0000
1.24
+++ javax/swing/plaf/basic/BasicSliderUI.java 27 Mar 2006 15:56:53 -0000
@@ -1201,13 +1201,17 @@
}
/**
- * This method returns the size of the thumbRect.
+ * Returns the size of the slider's thumb. The size is hard coded to
+ * <code>11 x 20</code> for horizontal sliders, and <code>20 x 11</code> for
+ * vertical sliders. Note that a new instance of [EMAIL PROTECTED]
Dimension} is
+ * returned for every call to this method (this seems wasteful, but
+ * [EMAIL PROTECTED] Dimension} instances are not immutable, so this is
probably
+ * unavoidable).
*
- * @return The dimensions of the thumb.
+ * @return The size of the slider's thumb.
*/
protected Dimension getThumbSize()
{
- // TODO: shouldn't create new objects every time
if (slider.getOrientation() == JSlider.HORIZONTAL)
return new Dimension(11, 20);
else