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