The width of a combobox is calculated incorrectly.
public Dimension getComboBoxPreferredSize(List cb) {
Dimension d = getListPreferredSize(cb);
if (comboImage != null) {
d.setWidth(d.getWidth() + comboImage.getWidth());
d.setHeight(Math.max(d.getHeight(), comboImage.getHeight()));
}
return d;
}
Now Dimension d = getListPreferredSize(cb) calls this:
public Dimension getListPreferredSize(List l) {
which calls this:
private Dimension getListPreferredSizeImpl(List l) {
// If combobox without ever importing the ComboBox class dependency
if(l.getOrientation() > List.HORIZONTAL) {
int boxWidth = l.getStyle().getFont().getHeight() + 2;
return new Dimension(boxWidth + selectedWidth + horizontalPadding, selectedHeight + verticalPadding);
} else {
if (l.getOrientation() == List.VERTICAL) {
return new Dimension(selectedWidth + horizontalPadding, selectedHeight + (height + l.getItemGap()) * (numOfcomponents - 1) + verticalPadding);
} else {
return new Dimension(selectedWidth + (width + l.getItemGap()) * (numOfcomponents - 1) + horizontalPadding, selectedHeight + verticalPadding);
}
}
As you can see if(l.getOrientation() > List.HORIZONTAL) { results in adding a
box width (which is anyway calculated incorrectly since comboImage was not
checked. Then after the getListPreferredSizeImpl call we return to the root
which again adds a box (this time correctly).
Original issue reported on code.google.com by jkoo...@gmail.com on 12 Jul 2012 at 3:59
Original issue reported on code.google.com by
jkoo...@gmail.com
on 12 Jul 2012 at 3:59