Fixed Issue 83; Transforming graphics context was introducing slight rounding errors in the font metrics measurements. Calculating string widths using compnent.getGraphics() would yield slightly smaller widths than calculating them using the active Graphics object.
The fix is to calculate the "minimum acceptable" width that erring components (JButtons and JLabels) can be given the current graphics context and checking to see if it's larger than the minimum width the JLabel is reporting (which is computed at creation time assuming an identity transform). If it's larger (ellipsis would be shown) then it changes the minimum size of the component to be the the nearest ceil(minAcceptableWidth).

The calculation for the minimum size involves measuring text, adding insets, affording for icons and icon gaps.

Also, when calculating the bounds of the component, insets were not being considered but should have been.

Only hackish element of this fix is that its only applied to JButton and JLabels right now since I think they're the only components I can think of that calculate their minimum sizes in this way.
1 parent 307f999 commit 773d6267e796c337a1dc5755e1b6100698633f84
@Allain Lalonde Allain Lalonde authored on 24 Jul 2009
Showing 2 changed files
View
examples/src/main/java/edu/umd/cs/piccolo/examples/pswing/PSwingExample2.java
View
extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java