CalculatedStyle style = getBox().getStyle();
BorderPropertySet border = style.getBorder(null);
boolean disableOSBorder = (border.leftStyle() != null && border.rightStyle() != null || border.topStyle() != null || border.bottomStyle() != null);
RectPropertySet padding = style.getCachedPadding();
Integer paddingTop = getLengthValue(style, CSSName.PADDING_TOP);
Integer paddingLeft = getLengthValue(style, CSSName.PADDING_LEFT);
Integer paddingBottom = getLengthValue(style, CSSName.PADDING_BOTTOM);
Integer paddingRight = getLengthValue(style, CSSName.PADDING_RIGHT);
int top = paddingTop == null ? 2 : Math.max(2, paddingTop.intValue());
int left = paddingLeft == null ? 3 : Math.max(3, paddingLeft.intValue());
int bottom = paddingBottom == null ? 2 : Math.max(2, paddingBottom.intValue());
int right = paddingRight == null ? 3 : Math.max(3, paddingRight.intValue());
//if a border is set or a background color is set, then use a special JButton with the BasicButtonUI.
if (disableOSBorder) {
//when background color is set, need to use the BasicButtonUI, certainly when using XP l&f
BasicTextUI ui = new BasicTextFieldUI();
field.setUI(ui);
Border fieldBorder = BorderFactory.createEmptyBorder(top, left, bottom, right);
field.setBorder(fieldBorder);
}
else {
field.setMargin(new Insets(top, left, bottom, right));
}
padding.setRight(0);
padding.setLeft(0);
padding.setTop(0);
padding.setBottom(0);
FSDerivedValue widthValue = style.valueByName(CSSName.WIDTH);
if (widthValue instanceof LengthValue) {
intrinsicWidth = new Integer(getBox().getContentWidth() + left + right);
}