mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +03:00
ComboBox and Spinner: fixed too wide arrow button if component is higher than preferred (issue #302)
This commit is contained in:
@@ -28,6 +28,8 @@ FlatLaf Change Log
|
|||||||
- IntelliJ Themes: Fixed system colors.
|
- IntelliJ Themes: Fixed system colors.
|
||||||
- Button and ToggleButton: Do not paint background of disabled (and unselected)
|
- Button and ToggleButton: Do not paint background of disabled (and unselected)
|
||||||
toolBar buttons. (issue #292; regression since fixing #112)
|
toolBar buttons. (issue #292; regression since fixing #112)
|
||||||
|
- ComboBox and Spinner: Fixed too wide arrow button if component is higher than
|
||||||
|
preferred. (issue #302)
|
||||||
- SplitPane: `JSplitPane.setContinuousLayout(false)` did not work. (issue #301)
|
- SplitPane: `JSplitPane.setContinuousLayout(false)` did not work. (issue #301)
|
||||||
- TabbedPane: Fixed NPE when creating/modifying in another thread. (issue #299)
|
- TabbedPane: Fixed NPE when creating/modifying in another thread. (issue #299)
|
||||||
- Fixed crash when running in Webswing. (issue #290)
|
- Fixed crash when running in Webswing. (issue #290)
|
||||||
|
|||||||
@@ -243,7 +243,24 @@ public class FlatComboBoxUI
|
|||||||
public void layoutContainer( Container parent ) {
|
public void layoutContainer( Container parent ) {
|
||||||
super.layoutContainer( 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
|
// fix editor bounds by subtracting padding
|
||||||
editor.setBounds( FlatUIUtils.subtractInsets( editor.getBounds(), padding ) );
|
editor.setBounds( FlatUIUtils.subtractInsets( editor.getBounds(), padding ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -375,8 +375,8 @@ public class FlatSpinnerUI
|
|||||||
Rectangle editorRect = new Rectangle( r );
|
Rectangle editorRect = new Rectangle( r );
|
||||||
Rectangle buttonsRect = new Rectangle( r );
|
Rectangle buttonsRect = new Rectangle( r );
|
||||||
|
|
||||||
// make button area square
|
// make button area square (if spinner has preferred height)
|
||||||
int buttonsWidth = r.height;
|
int buttonsWidth = parent.getPreferredSize().height - insets.top - insets.bottom;
|
||||||
buttonsRect.width = buttonsWidth;
|
buttonsRect.width = buttonsWidth;
|
||||||
|
|
||||||
if( parent.getComponentOrientation().isLeftToRight() ) {
|
if( parent.getComponentOrientation().isLeftToRight() ) {
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ public class FlatTextComponentsTest
|
|||||||
JComboBox<String> comboBox3 = new JComboBox<>();
|
JComboBox<String> comboBox3 = new JComboBox<>();
|
||||||
JLabel spinnerLabel = new JLabel();
|
JLabel spinnerLabel = new JLabel();
|
||||||
JSpinner spinner1 = new JSpinner();
|
JSpinner spinner1 = new JSpinner();
|
||||||
|
JSpinner spinner2 = new JSpinner();
|
||||||
|
JSpinner spinner3 = new JSpinner();
|
||||||
|
JComboBox comboBox2 = new JComboBox();
|
||||||
|
JComboBox comboBox4 = new JComboBox();
|
||||||
JPopupMenu popupMenu1 = new JPopupMenu();
|
JPopupMenu popupMenu1 = new JPopupMenu();
|
||||||
JMenuItem cutMenuItem = new JMenuItem();
|
JMenuItem cutMenuItem = new JMenuItem();
|
||||||
JMenuItem copyMenuItem = new JMenuItem();
|
JMenuItem copyMenuItem = new JMenuItem();
|
||||||
@@ -97,6 +101,10 @@ public class FlatTextComponentsTest
|
|||||||
"[50,fill]" +
|
"[50,fill]" +
|
||||||
"[50,fill]" +
|
"[50,fill]" +
|
||||||
"[]" +
|
"[]" +
|
||||||
|
"[]para" +
|
||||||
|
"[]" +
|
||||||
|
"[]" +
|
||||||
|
"[]" +
|
||||||
"[]"));
|
"[]"));
|
||||||
|
|
||||||
//---- textFieldLabel ----
|
//---- textFieldLabel ----
|
||||||
@@ -307,6 +315,24 @@ public class FlatTextComponentsTest
|
|||||||
spinner1.setName("spinner1");
|
spinner1.setName("spinner1");
|
||||||
add(spinner1, "cell 1 7,growx");
|
add(spinner1, "cell 1 7,growx");
|
||||||
|
|
||||||
|
//---- spinner2 ----
|
||||||
|
spinner2.setName("spinner2");
|
||||||
|
add(spinner2, "cell 1 8,growx,height 40");
|
||||||
|
|
||||||
|
//---- spinner3 ----
|
||||||
|
spinner3.setName("spinner3");
|
||||||
|
add(spinner3, "cell 1 9,growx,hmax 14");
|
||||||
|
|
||||||
|
//---- comboBox2 ----
|
||||||
|
comboBox2.setEditable(true);
|
||||||
|
comboBox2.setName("comboBox2");
|
||||||
|
add(comboBox2, "cell 1 10,growx,height 40");
|
||||||
|
|
||||||
|
//---- comboBox4 ----
|
||||||
|
comboBox4.setEditable(true);
|
||||||
|
comboBox4.setName("comboBox4");
|
||||||
|
add(comboBox4, "cell 1 11,growx,hmax 14");
|
||||||
|
|
||||||
//======== popupMenu1 ========
|
//======== popupMenu1 ========
|
||||||
{
|
{
|
||||||
popupMenu1.setName("popupMenu1");
|
popupMenu1.setName("popupMenu1");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
JFDML JFormDesigner: "7.0.0.0.194" Java: "13.0.1" encoding: "UTF-8"
|
JFDML JFormDesigner: "7.0.3.1.342" Java: "16" encoding: "UTF-8"
|
||||||
|
|
||||||
new FormModel {
|
new FormModel {
|
||||||
contentType: "form/swing"
|
contentType: "form/swing"
|
||||||
@@ -10,7 +10,7 @@ new FormModel {
|
|||||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
|
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
|
||||||
"$columnConstraints": "[][][::100][100,fill][fill]"
|
"$columnConstraints": "[][][::100][100,fill][fill]"
|
||||||
"$rowConstraints": "[][][][50,fill][50,fill][50,fill][][]"
|
"$rowConstraints": "[][][][50,fill][50,fill][50,fill][][]para[][][][]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "this"
|
name: "this"
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
@@ -233,9 +233,31 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 7,growx"
|
"value": "cell 1 7,growx"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JSpinner" ) {
|
||||||
|
name: "spinner2"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 8,growx,height 40"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JSpinner" ) {
|
||||||
|
name: "spinner3"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 9,growx,hmax 14"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||||
|
name: "comboBox2"
|
||||||
|
"editable": true
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 10,growx,height 40"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||||
|
name: "comboBox4"
|
||||||
|
"editable": true
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 11,growx,hmax 14"
|
||||||
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
"size": new java.awt.Dimension( 530, 340 )
|
"size": new java.awt.Dimension( 530, 580 )
|
||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JPopupMenu", new FormLayoutManager( class javax.swing.JPopupMenu ) ) {
|
add( new FormContainer( "javax.swing.JPopupMenu", new FormLayoutManager( class javax.swing.JPopupMenu ) ) {
|
||||||
name: "popupMenu1"
|
name: "popupMenu1"
|
||||||
@@ -252,7 +274,7 @@ new FormModel {
|
|||||||
"text": "Paste"
|
"text": "Paste"
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 390 )
|
"location": new java.awt.Point( 0, 680 )
|
||||||
"size": new java.awt.Dimension( 91, 87 )
|
"size": new java.awt.Dimension( 91, 87 )
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user