mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
TextField: support "clear" (or "cancel") button to empty text field
This commit is contained in:
@@ -144,6 +144,26 @@ public class FlatFormattedTextField
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether a "clear" (or "cancel") button is shown.
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public boolean isShowClearButton() {
|
||||
return getClientPropertyBoolean( TEXT_FIELD_SHOW_CLEAR_BUTTON, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether a "clear" (or "cancel") button is shown on the trailing side
|
||||
* if the text field is not empty, editable and enabled.
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public void setShowClearButton( boolean showClearButton ) {
|
||||
putClientPropertyBoolean( TEXT_FIELD_SHOW_CLEAR_BUTTON, showClearButton, false );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether all text is selected when the text component gains focus.
|
||||
*/
|
||||
|
||||
@@ -144,6 +144,26 @@ public class FlatPasswordField
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether a "clear" (or "cancel") button is shown.
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public boolean isShowClearButton() {
|
||||
return getClientPropertyBoolean( TEXT_FIELD_SHOW_CLEAR_BUTTON, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether a "clear" (or "cancel") button is shown on the trailing side
|
||||
* if the text field is not empty, editable and enabled.
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public void setShowClearButton( boolean showClearButton ) {
|
||||
putClientPropertyBoolean( TEXT_FIELD_SHOW_CLEAR_BUTTON, showClearButton, false );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether all text is selected when the text component gains focus.
|
||||
*/
|
||||
|
||||
@@ -143,6 +143,26 @@ public class FlatTextField
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether a "clear" (or "cancel") button is shown.
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public boolean isShowClearButton() {
|
||||
return getClientPropertyBoolean( TEXT_FIELD_SHOW_CLEAR_BUTTON, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether a "clear" (or "cancel") button is shown on the trailing side
|
||||
* if the text field is not empty, editable and enabled.
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public void setShowClearButton( boolean showClearButton ) {
|
||||
putClientPropertyBoolean( TEXT_FIELD_SHOW_CLEAR_BUTTON, showClearButton, false );
|
||||
}
|
||||
|
||||
|
||||
// NOTE: enum names must be equal to allowed strings
|
||||
public enum SelectAllOnFocusPolicy { never, once, always };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user