mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
TextField and TextArea: do not apply minimum width if columns property > 0
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
FlatLaf Change Log
|
||||
==================
|
||||
|
||||
## Unreleased
|
||||
|
||||
- TextField and TextArea: Do not apply minimum width if `columns` property is
|
||||
greater than zero.
|
||||
|
||||
|
||||
## 0.17
|
||||
|
||||
- CheckBox: Support painting a third state (set client property
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
@@ -81,15 +82,19 @@ public class FlatTextAreaUI
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize( JComponent c ) {
|
||||
return applyMinimumWidth( super.getPreferredSize( c ) );
|
||||
return applyMinimumWidth( super.getPreferredSize( c ), c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize( JComponent c ) {
|
||||
return applyMinimumWidth( super.getMinimumSize( c ) );
|
||||
return applyMinimumWidth( super.getMinimumSize( c ), c );
|
||||
}
|
||||
|
||||
private Dimension applyMinimumWidth( Dimension size ) {
|
||||
private Dimension applyMinimumWidth( Dimension size, JComponent c ) {
|
||||
// do not apply minimum width if JTextArea.columns is set
|
||||
if( c instanceof JTextArea && ((JTextArea)c).getColumns() > 0 )
|
||||
return size;
|
||||
|
||||
// Assume that text area is in a scroll pane (that displays the border)
|
||||
// and subtract 1px border line width.
|
||||
// Using "(scale( 1 ) * 2)" instead of "scale( 2 )" to deal with rounding
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.awt.event.FocusListener;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
@@ -137,6 +138,10 @@ public class FlatTextFieldUI
|
||||
}
|
||||
|
||||
private Dimension applyMinimumWidth( Dimension size, JComponent c ) {
|
||||
// do not apply minimum width if JTextField.columns is set
|
||||
if( c instanceof JTextField && ((JTextField)c).getColumns() > 0 )
|
||||
return size;
|
||||
|
||||
Container parent = c.getParent();
|
||||
if( parent instanceof JComboBox ||
|
||||
parent instanceof JSpinner ||
|
||||
|
||||
Reference in New Issue
Block a user