-
Bug
-
Resolution: Fixed
-
P4
-
1.3.0
-
beta
-
generic
-
generic
Name: skT45625 Date: 11/02/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
BasicGraphicsUtils.getPreferredButtonSize() is used to get the preferred size
of classes extended from AbstractButton, for instance JButton using the basic
LAF. The last lines of that function from the 1.3 source are:
----------
/* Ensure that the width and height of the button is odd,
* to allow for the focus line.
*/
if(r.width % 2 == 0) { r.width += 1; }
if(r.height % 2 == 0) { r.height += 1; }
return r.getSize();
----------
where r is a Rectangle object. so if I have a JButton with a 32x32 icon, and
no text, r is computed to be 32x32, and then the above code adjusts it to be
33x33.
The problem is, the above code makes no checks for isFocusPainted() (or
isContentAreaFilled(), possibly), so even if no focus or contentarea is painted
(e.g. with setFocusPainted(false) and setContentAreaFilled(false)), JButtons
are still padded with an extra pixel for the width and the height, wreaking
havoc on developers trying to make icon-only icons with extra adornment. The
javadoc for isContentAreaFilled mentions just such a scenario as something a
developer might want to do; with this code the way it is it is not possible to
have a truly icon-only button without rewrite UI classes, which is undesirable.
If there is some good reason why the BasicGraphicUtils is written this way, or
why the Basic LAF is, I stand corrected, but I think it should be desirable to
allow developers to make JButtons truly icon-only without overriding/rewriting
Swing UI classes, but instead using methods already provided that would seem to
allow this functionality.
(Review ID: 111740)
======================================================================