mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 22:47:13 -06:00
ComboBox and Spinner: fixed too wide arrow button if component is higher than preferred (issue #302)
This commit is contained in:
@@ -243,7 +243,24 @@ public class FlatComboBoxUI
|
||||
public void layoutContainer( Container parent ) {
|
||||
super.layoutContainer( parent );
|
||||
|
||||
if ( editor != null && padding != null ) {
|
||||
if( arrowButton != null ) {
|
||||
Insets insets = getInsets();
|
||||
int buttonWidth = parent.getPreferredSize().height - insets.top - insets.bottom;
|
||||
if( buttonWidth != arrowButton.getWidth() ) {
|
||||
// set width of arrow button to preferred height of combobox
|
||||
int xOffset = comboBox.getComponentOrientation().isLeftToRight()
|
||||
? arrowButton.getWidth() - buttonWidth
|
||||
: 0;
|
||||
arrowButton.setBounds( arrowButton.getX() + xOffset, arrowButton.getY(),
|
||||
buttonWidth, arrowButton.getHeight() );
|
||||
|
||||
// update editor bounds
|
||||
if( editor != null )
|
||||
editor.setBounds( rectangleForCurrentValue() );
|
||||
}
|
||||
}
|
||||
|
||||
if( editor != null && padding != null ) {
|
||||
// fix editor bounds by subtracting padding
|
||||
editor.setBounds( FlatUIUtils.subtractInsets( editor.getBounds(), padding ) );
|
||||
}
|
||||
|
||||
@@ -375,8 +375,8 @@ public class FlatSpinnerUI
|
||||
Rectangle editorRect = new Rectangle( r );
|
||||
Rectangle buttonsRect = new Rectangle( r );
|
||||
|
||||
// make button area square
|
||||
int buttonsWidth = r.height;
|
||||
// make button area square (if spinner has preferred height)
|
||||
int buttonsWidth = parent.getPreferredSize().height - insets.top - insets.bottom;
|
||||
buttonsRect.width = buttonsWidth;
|
||||
|
||||
if( parent.getComponentOrientation().isLeftToRight() ) {
|
||||
|
||||
Reference in New Issue
Block a user