mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
TextField: support leading and trailing icons (issue #368)
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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 };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user