diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java index 4f398439..0fb5e513 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -874,7 +874,26 @@ public interface FlatClientProperties * The component should be not opaque because the text field border is painted * slightly inside the usually visible border in some cases. * E.g. when focused (in some themes) or when an outline color is specified - * (see {@link #OUTLINE}. + * (see {@link #OUTLINE}). + *
+ * The component is prepared in the following way: + *
+ * Styling is used to modify insets/margins and appearance of buttons and toolbars + * so that they fit nicely into the text field and do not increase text field height. + * See styles {@code [style]Button.inTextField} and {@code [style]ToolBar.inTextField} + * in {@code Flat[Light|Dark]Laf.properties}. *
* Component {@link javax.swing.JTextField} (and subclasses)
* Value type {@link javax.swing.JComponent}
@@ -886,15 +905,7 @@ public interface FlatClientProperties
/**
* Specifies a component that will be placed at the trailing edge of the text field.
*
- * The component will be positioned inside and aligned to the visible text field border. - * There is no gap between the visible border and the component. - * The laid out component size will be the preferred component width - * and the inner text field height. - *
- * The component should be not opaque because the text field border is painted - * slightly inside the usually visible border in some cases. - * E.g. when focused (in some themes) or when an outline color is specified - * (see {@link #OUTLINE}. + * See {@link #TEXT_FIELD_LEADING_COMPONENT} for details. *
* Component {@link javax.swing.JTextField} (and subclasses)
* Value type {@link javax.swing.JComponent}
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java
index 66c7056d..65876191 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java
@@ -826,15 +826,20 @@ debug*/
/** @since 2 */
protected void prepareLeadingOrTrailingComponent( JComponent c ) {
c.putClientProperty( STYLE_CLASS, "inTextField" );
- c.setCursor( Cursor.getDefaultCursor() );
- if( c instanceof JButton || c instanceof JToggleButton )
+ if( c instanceof JButton || c instanceof JToggleButton ) {
c.putClientProperty( BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON );
- else if( c instanceof JToolBar ) {
+
+ if( !c.isCursorSet() )
+ c.setCursor( Cursor.getDefaultCursor() );
+ } else if( c instanceof JToolBar ) {
for( Component child : c.getComponents() ) {
if( child instanceof JComponent )
((JComponent)child).putClientProperty( STYLE_CLASS, "inTextField" );
}
+
+ if( !c.isCursorSet() )
+ c.setCursor( Cursor.getDefaultCursor() );
}
}