From 94375b7d36dc6ae02309f5dcc04d2cae38b3601b Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 10 Jul 2021 20:59:34 +0200 Subject: [PATCH] Extras: added support for client property `JTextField.padding` (for commit a9dcf09d1312743519c9874fb450f8ac2542856d) --- .../components/FlatFormattedTextField.java | 22 +++++++++++++++++++ .../extras/components/FlatPasswordField.java | 22 +++++++++++++++++++ .../extras/components/FlatTextField.java | 22 +++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatFormattedTextField.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatFormattedTextField.java index 5f943bfe..4ebc554d 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatFormattedTextField.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatFormattedTextField.java @@ -18,6 +18,7 @@ package com.formdev.flatlaf.extras.components; import static com.formdev.flatlaf.FlatClientProperties.*; import java.awt.Color; +import java.awt.Insets; import javax.swing.JFormattedTextField; import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolicy; @@ -61,6 +62,27 @@ public class FlatFormattedTextField } + /** + * Returns the padding of the text. + * + * @since 1.4 + */ + public Insets getPadding() { + return (Insets) getClientProperty( TEXT_FIELD_PADDING ); + } + + /** + * Specifies the padding of the text. + * This changes the location and size of the text view within the component bounds, + * but does not affect the size of the component. + * + * @since 1.4 + */ + public void setPadding( Insets padding ) { + putClientProperty( TEXT_FIELD_PADDING, padding ); + } + + /** * Returns minimum width of a component. */ diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPasswordField.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPasswordField.java index 93b88299..86495da2 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPasswordField.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPasswordField.java @@ -18,6 +18,7 @@ package com.formdev.flatlaf.extras.components; import static com.formdev.flatlaf.FlatClientProperties.*; import java.awt.Color; +import java.awt.Insets; import javax.swing.JPasswordField; import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolicy; @@ -61,6 +62,27 @@ public class FlatPasswordField } + /** + * Returns the padding of the text. + * + * @since 1.4 + */ + public Insets getPadding() { + return (Insets) getClientProperty( TEXT_FIELD_PADDING ); + } + + /** + * Specifies the padding of the text. + * This changes the location and size of the text view within the component bounds, + * but does not affect the size of the component. + * + * @since 1.4 + */ + public void setPadding( Insets padding ) { + putClientProperty( TEXT_FIELD_PADDING, padding ); + } + + /** * Returns minimum width of a component. */ diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextField.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextField.java index a43d195b..bfa22dd2 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextField.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextField.java @@ -18,6 +18,7 @@ package com.formdev.flatlaf.extras.components; import static com.formdev.flatlaf.FlatClientProperties.*; import java.awt.Color; +import java.awt.Insets; import javax.swing.JTextField; /** @@ -63,6 +64,27 @@ public class FlatTextField } + /** + * Returns the padding of the text. + * + * @since 1.4 + */ + public Insets getPadding() { + return (Insets) getClientProperty( TEXT_FIELD_PADDING ); + } + + /** + * Specifies the padding of the text. + * This changes the location and size of the text view within the component bounds, + * but does not affect the size of the component. + * + * @since 1.4 + */ + public void setPadding( Insets padding ) { + putClientProperty( TEXT_FIELD_PADDING, padding ); + } + + /** * Returns minimum width of a component. */