mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
TextField: require JComponent for leading and trailing components (to allow setting a style class client property)
This commit is contained in:
@@ -877,7 +877,7 @@ public interface FlatClientProperties
|
||||
* (see {@link #OUTLINE}.
|
||||
* <p>
|
||||
* <strong>Component</strong> {@link javax.swing.JTextField} (and subclasses)<br>
|
||||
* <strong>Value type</strong> {@link java.awt.Component}
|
||||
* <strong>Value type</strong> {@link javax.swing.JComponent}
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
@@ -897,7 +897,7 @@ public interface FlatClientProperties
|
||||
* (see {@link #OUTLINE}.
|
||||
* <p>
|
||||
* <strong>Component</strong> {@link javax.swing.JTextField} (and subclasses)<br>
|
||||
* <strong>Value type</strong> {@link java.awt.Component}
|
||||
* <strong>Value type</strong> {@link javax.swing.JComponent}
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
|
||||
@@ -97,8 +97,8 @@ public class FlatTextFieldUI
|
||||
|
||||
/** @since 2 */ @Styleable protected Icon leadingIcon;
|
||||
/** @since 2 */ @Styleable protected Icon trailingIcon;
|
||||
/** @since 2 */ protected Component leadingComponent;
|
||||
/** @since 2 */ protected Component trailingComponent;
|
||||
/** @since 2 */ protected JComponent leadingComponent;
|
||||
/** @since 2 */ protected JComponent trailingComponent;
|
||||
|
||||
private Color oldDisabledBackground;
|
||||
private Color oldInactiveBackground;
|
||||
@@ -554,8 +554,8 @@ debug*/
|
||||
boolean ltr = isLeftToRight();
|
||||
|
||||
// remove width of leading/trailing components
|
||||
Component leftComponent = ltr ? leadingComponent : trailingComponent;
|
||||
Component rightComponent = ltr ? trailingComponent : leadingComponent;
|
||||
JComponent leftComponent = ltr ? leadingComponent : trailingComponent;
|
||||
JComponent rightComponent = ltr ? trailingComponent : leadingComponent;
|
||||
if( leftComponent != null ) {
|
||||
int w = leftComponent.getPreferredSize().width;
|
||||
r.x += w;
|
||||
@@ -634,7 +634,7 @@ debug*/
|
||||
/** @since 2 */
|
||||
protected void installLeadingComponent() {
|
||||
JTextComponent c = getComponent();
|
||||
leadingComponent = clientProperty( c, TEXT_FIELD_LEADING_COMPONENT, null, Component.class );
|
||||
leadingComponent = clientProperty( c, TEXT_FIELD_LEADING_COMPONENT, null, JComponent.class );
|
||||
if( leadingComponent != null ) {
|
||||
installLayout();
|
||||
c.add( leadingComponent );
|
||||
@@ -644,7 +644,7 @@ debug*/
|
||||
/** @since 2 */
|
||||
protected void installTrailingComponent() {
|
||||
JTextComponent c = getComponent();
|
||||
trailingComponent = clientProperty( c, TEXT_FIELD_TRAILING_COMPONENT, null, Component.class );
|
||||
trailingComponent = clientProperty( c, TEXT_FIELD_TRAILING_COMPONENT, null, JComponent.class );
|
||||
if( trailingComponent != null ) {
|
||||
installLayout();
|
||||
c.add( trailingComponent );
|
||||
@@ -718,8 +718,8 @@ debug*/
|
||||
int ow = FlatUIUtils.getBorderFocusAndLineWidth( getComponent() );
|
||||
int h = parent.getHeight() - ow - ow;
|
||||
boolean ltr = isLeftToRight();
|
||||
Component leftComponent = ltr ? leadingComponent : trailingComponent;
|
||||
Component rightComponent = ltr ? trailingComponent : leadingComponent;
|
||||
JComponent leftComponent = ltr ? leadingComponent : trailingComponent;
|
||||
JComponent rightComponent = ltr ? trailingComponent : leadingComponent;
|
||||
|
||||
// layout left component
|
||||
if( leftComponent != null && leftComponent.isVisible() ) {
|
||||
|
||||
@@ -18,9 +18,9 @@ package com.formdev.flatlaf.extras.components;
|
||||
|
||||
import static com.formdev.flatlaf.FlatClientProperties.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFormattedTextField;
|
||||
import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolicy;
|
||||
|
||||
@@ -91,8 +91,8 @@ public class FlatFormattedTextField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public Component getLeadingComponent() {
|
||||
return (Component) getClientProperty( TEXT_FIELD_LEADING_COMPONENT );
|
||||
public JComponent getLeadingComponent() {
|
||||
return (JComponent) getClientProperty( TEXT_FIELD_LEADING_COMPONENT );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ public class FlatFormattedTextField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public void setLeadingComponent( Component leadingComponent ) {
|
||||
public void setLeadingComponent( JComponent leadingComponent ) {
|
||||
putClientProperty( TEXT_FIELD_LEADING_COMPONENT, leadingComponent );
|
||||
}
|
||||
|
||||
@@ -120,8 +120,8 @@ public class FlatFormattedTextField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public Component getTrailingComponent() {
|
||||
return (Component) getClientProperty( TEXT_FIELD_TRAILING_COMPONENT );
|
||||
public JComponent getTrailingComponent() {
|
||||
return (JComponent) getClientProperty( TEXT_FIELD_TRAILING_COMPONENT );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ public class FlatFormattedTextField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public void setTrailingComponent( Component trailingComponent ) {
|
||||
public void setTrailingComponent( JComponent trailingComponent ) {
|
||||
putClientProperty( TEXT_FIELD_TRAILING_COMPONENT, trailingComponent );
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ package com.formdev.flatlaf.extras.components;
|
||||
|
||||
import static com.formdev.flatlaf.FlatClientProperties.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPasswordField;
|
||||
import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolicy;
|
||||
|
||||
@@ -91,8 +91,8 @@ public class FlatPasswordField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public Component getLeadingComponent() {
|
||||
return (Component) getClientProperty( TEXT_FIELD_LEADING_COMPONENT );
|
||||
public JComponent getLeadingComponent() {
|
||||
return (JComponent) getClientProperty( TEXT_FIELD_LEADING_COMPONENT );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ public class FlatPasswordField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public void setLeadingComponent( Component leadingComponent ) {
|
||||
public void setLeadingComponent( JComponent leadingComponent ) {
|
||||
putClientProperty( TEXT_FIELD_LEADING_COMPONENT, leadingComponent );
|
||||
}
|
||||
|
||||
@@ -120,8 +120,8 @@ public class FlatPasswordField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public Component getTrailingComponent() {
|
||||
return (Component) getClientProperty( TEXT_FIELD_TRAILING_COMPONENT );
|
||||
public JComponent getTrailingComponent() {
|
||||
return (JComponent) getClientProperty( TEXT_FIELD_TRAILING_COMPONENT );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ public class FlatPasswordField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public void setTrailingComponent( Component trailingComponent ) {
|
||||
public void setTrailingComponent( JComponent trailingComponent ) {
|
||||
putClientProperty( TEXT_FIELD_TRAILING_COMPONENT, trailingComponent );
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ package com.formdev.flatlaf.extras.components;
|
||||
|
||||
import static com.formdev.flatlaf.FlatClientProperties.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
/**
|
||||
@@ -90,8 +90,8 @@ public class FlatTextField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public Component getLeadingComponent() {
|
||||
return (Component) getClientProperty( TEXT_FIELD_LEADING_COMPONENT );
|
||||
public JComponent getLeadingComponent() {
|
||||
return (JComponent) getClientProperty( TEXT_FIELD_LEADING_COMPONENT );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +109,7 @@ public class FlatTextField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public void setLeadingComponent( Component leadingComponent ) {
|
||||
public void setLeadingComponent( JComponent leadingComponent ) {
|
||||
putClientProperty( TEXT_FIELD_LEADING_COMPONENT, leadingComponent );
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ public class FlatTextField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public Component getTrailingComponent() {
|
||||
return (Component) getClientProperty( TEXT_FIELD_TRAILING_COMPONENT );
|
||||
public JComponent getTrailingComponent() {
|
||||
return (JComponent) getClientProperty( TEXT_FIELD_TRAILING_COMPONENT );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +138,7 @@ public class FlatTextField
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
public void setTrailingComponent( Component trailingComponent ) {
|
||||
public void setTrailingComponent( JComponent trailingComponent ) {
|
||||
putClientProperty( TEXT_FIELD_TRAILING_COMPONENT, trailingComponent );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user