mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-14 07:47:12 -06:00
PasswordField: do not apply minimum width if columns property > 0
This commit is contained in:
@@ -18,6 +18,8 @@ FlatLaf Change Log
|
|||||||
radio button is used as table cell renderer. (issue #77)
|
radio button is used as table cell renderer. (issue #77)
|
||||||
- FileChooser: Fixed missing labels in file chooser when running on Java 9 or
|
- FileChooser: Fixed missing labels in file chooser when running on Java 9 or
|
||||||
later. (issue #98)
|
later. (issue #98)
|
||||||
|
- PasswordField: Do not apply minimum width if `columns` property is greater
|
||||||
|
than zero.
|
||||||
|
|
||||||
|
|
||||||
## 0.34
|
## 0.34
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@@ -175,18 +174,11 @@ public class FlatPasswordFieldUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize( JComponent c ) {
|
public Dimension getPreferredSize( JComponent c ) {
|
||||||
return applyMinimumWidth( super.getPreferredSize( c ), c );
|
return FlatTextFieldUI.applyMinimumWidth( super.getPreferredSize( c ), minimumWidth, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getMinimumSize( JComponent c ) {
|
public Dimension getMinimumSize( JComponent c ) {
|
||||||
return applyMinimumWidth( super.getMinimumSize( c ), c );
|
return FlatTextFieldUI.applyMinimumWidth( super.getMinimumSize( c ), minimumWidth, c );
|
||||||
}
|
|
||||||
|
|
||||||
private Dimension applyMinimumWidth( Dimension size, JComponent c ) {
|
|
||||||
int minimumWidth = FlatUIUtils.minimumWidth( getComponent(), this.minimumWidth );
|
|
||||||
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
|
|
||||||
size.width = Math.max( size.width, scale( minimumWidth ) + Math.round( focusWidth * 2 ) );
|
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,26 +213,27 @@ public class FlatTextFieldUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize( JComponent c ) {
|
public Dimension getPreferredSize( JComponent c ) {
|
||||||
return applyMinimumWidth( super.getPreferredSize( c ), c );
|
return applyMinimumWidth( super.getPreferredSize( c ), minimumWidth, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getMinimumSize( JComponent c ) {
|
public Dimension getMinimumSize( JComponent c ) {
|
||||||
return applyMinimumWidth( super.getMinimumSize( c ), c );
|
return applyMinimumWidth( super.getMinimumSize( c ), minimumWidth, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dimension applyMinimumWidth( Dimension size, JComponent c ) {
|
static Dimension applyMinimumWidth( Dimension size, int minimumWidth, JComponent c ) {
|
||||||
// do not apply minimum width if JTextField.columns is set
|
// do not apply minimum width if JTextField.columns is set
|
||||||
if( c instanceof JTextField && ((JTextField)c).getColumns() > 0 )
|
if( c instanceof JTextField && ((JTextField)c).getColumns() > 0 )
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
|
// do not apply minimum width if used in combobox or spinner
|
||||||
Container parent = c.getParent();
|
Container parent = c.getParent();
|
||||||
if( parent instanceof JComboBox ||
|
if( parent instanceof JComboBox ||
|
||||||
parent instanceof JSpinner ||
|
parent instanceof JSpinner ||
|
||||||
(parent != null && parent.getParent() instanceof JSpinner) )
|
(parent != null && parent.getParent() instanceof JSpinner) )
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
int minimumWidth = FlatUIUtils.minimumWidth( getComponent(), this.minimumWidth );
|
minimumWidth = FlatUIUtils.minimumWidth( c, minimumWidth );
|
||||||
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
|
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
|
||||||
size.width = Math.max( size.width, scale( minimumWidth ) + Math.round( focusWidth * 2 ) );
|
size.width = Math.max( size.width, scale( minimumWidth ) + Math.round( focusWidth * 2 ) );
|
||||||
return size;
|
return size;
|
||||||
|
|||||||
Reference in New Issue
Block a user