Merge PR #378: TextField: leading and trailing icons

# Conflicts:
#	flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPasswordFieldUI.java
#	flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java
This commit is contained in:
Karl Tauber
2021-09-15 23:32:57 +02:00
21 changed files with 577 additions and 78 deletions

View File

@@ -19,6 +19,7 @@ package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import java.awt.Insets;
import javax.swing.Icon;
import javax.swing.JFormattedTextField;
import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolicy;
@@ -46,6 +47,44 @@ public class FlatFormattedTextField
}
/**
* Returns the leading icon that will be placed at the leading edge of the text field.
*
* @since 2
*/
public Icon getLeadingIcon() {
return (Icon) getClientProperty( TEXT_FIELD_LEADING_ICON );
}
/**
* Specifies the leading icon that will be placed at the leading edge of the text field.
*
* @since 2
*/
public void setLeadingIcon( Icon leadingIcon ) {
putClientProperty( TEXT_FIELD_LEADING_ICON, leadingIcon );
}
/**
* Returns the trailing icon that will be placed at the trailing edge of the text field.
*
* @since 2
*/
public Icon getTrailingIcon() {
return (Icon) getClientProperty( TEXT_FIELD_TRAILING_ICON );
}
/**
* Specifies the trailing icon that will be placed at the trailing edge of the text field.
*
* @since 2
*/
public void setTrailingIcon( Icon trailingIcon ) {
putClientProperty( TEXT_FIELD_TRAILING_ICON, trailingIcon );
}
/**
* Returns whether all text is selected when the text component gains focus.
*/

View File

@@ -19,6 +19,7 @@ package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import java.awt.Insets;
import javax.swing.Icon;
import javax.swing.JPasswordField;
import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolicy;
@@ -46,6 +47,44 @@ public class FlatPasswordField
}
/**
* Returns the leading icon that will be placed at the leading edge of the text field.
*
* @since 2
*/
public Icon getLeadingIcon() {
return (Icon) getClientProperty( TEXT_FIELD_LEADING_ICON );
}
/**
* Specifies the leading icon that will be placed at the leading edge of the text field.
*
* @since 2
*/
public void setLeadingIcon( Icon leadingIcon ) {
putClientProperty( TEXT_FIELD_LEADING_ICON, leadingIcon );
}
/**
* Returns the trailing icon that will be placed at the trailing edge of the text field.
*
* @since 2
*/
public Icon getTrailingIcon() {
return (Icon) getClientProperty( TEXT_FIELD_TRAILING_ICON );
}
/**
* Specifies the trailing icon that will be placed at the trailing edge of the text field.
*
* @since 2
*/
public void setTrailingIcon( Icon trailingIcon ) {
putClientProperty( TEXT_FIELD_TRAILING_ICON, trailingIcon );
}
/**
* Returns whether all text is selected when the text component gains focus.
*/

View File

@@ -19,6 +19,7 @@ package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import java.awt.Insets;
import javax.swing.Icon;
import javax.swing.JTextField;
/**
@@ -45,6 +46,44 @@ public class FlatTextField
}
/**
* Returns the leading icon that will be placed at the leading edge of the text field.
*
* @since 2
*/
public Icon getLeadingIcon() {
return (Icon) getClientProperty( TEXT_FIELD_LEADING_ICON );
}
/**
* Specifies the leading icon that will be placed at the leading edge of the text field.
*
* @since 2
*/
public void setLeadingIcon( Icon leadingIcon ) {
putClientProperty( TEXT_FIELD_LEADING_ICON, leadingIcon );
}
/**
* Returns the trailing icon that will be placed at the trailing edge of the text field.
*
* @since 2
*/
public Icon getTrailingIcon() {
return (Icon) getClientProperty( TEXT_FIELD_TRAILING_ICON );
}
/**
* Specifies the trailing icon that will be placed at the trailing edge of the text field.
*
* @since 2
*/
public void setTrailingIcon( Icon trailingIcon ) {
putClientProperty( TEXT_FIELD_TRAILING_ICON, trailingIcon );
}
// NOTE: enum names must be equal to allowed strings
public enum SelectAllOnFocusPolicy { never, once, always };