mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-09 08:15:09 +03:00
Styling: support styling for recently merged changes
This commit is contained in:
@@ -22,10 +22,13 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import java.awt.geom.Line2D;
|
import java.awt.geom.Line2D;
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
|
import java.util.Map;
|
||||||
import javax.swing.AbstractButton;
|
import javax.swing.AbstractButton;
|
||||||
import javax.swing.ButtonModel;
|
import javax.swing.ButtonModel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
import com.formdev.flatlaf.ui.FlatStyleSupport;
|
||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
|
import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "clear" icon for search fields.
|
* "clear" icon for search fields.
|
||||||
@@ -40,14 +43,28 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
public class FlatClearIcon
|
public class FlatClearIcon
|
||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
protected Color clearIconColor = UIManager.getColor( "SearchField.clearIconColor" );
|
@Styleable protected Color clearIconColor = UIManager.getColor( "SearchField.clearIconColor" );
|
||||||
protected Color clearIconHoverColor = UIManager.getColor( "SearchField.clearIconHoverColor" );
|
@Styleable protected Color clearIconHoverColor = UIManager.getColor( "SearchField.clearIconHoverColor" );
|
||||||
protected Color clearIconPressedColor = UIManager.getColor( "SearchField.clearIconPressedColor" );
|
@Styleable protected Color clearIconPressedColor = UIManager.getColor( "SearchField.clearIconPressedColor" );
|
||||||
|
|
||||||
public FlatClearIcon() {
|
public FlatClearIcon() {
|
||||||
super( 16, 16, null );
|
super( 16, 16, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public Object applyStyleProperty( String key, Object value ) {
|
||||||
|
return FlatStyleSupport.applyToAnnotatedObject( this, key, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public Map<String, Class<?>> getStyleableInfos() {
|
||||||
|
return FlatStyleSupport.getAnnotatedStyleableInfos( this );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintIcon( Component c, Graphics2D g ) {
|
protected void paintIcon( Component c, Graphics2D g ) {
|
||||||
if( c instanceof AbstractButton ) {
|
if( c instanceof AbstractButton ) {
|
||||||
|
|||||||
@@ -21,9 +21,12 @@ import java.awt.Component;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
|
import java.util.Map;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import com.formdev.flatlaf.ui.FlatButtonUI;
|
import com.formdev.flatlaf.ui.FlatButtonUI;
|
||||||
|
import com.formdev.flatlaf.ui.FlatStyleSupport;
|
||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
|
import com.formdev.flatlaf.ui.FlatStyleSupport.Styleable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "search" icon for search fields.
|
* "search" icon for search fields.
|
||||||
@@ -38,14 +41,28 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
public class FlatSearchIcon
|
public class FlatSearchIcon
|
||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
protected Color searchIconColor = UIManager.getColor( "SearchField.searchIconColor" );
|
@Styleable protected Color searchIconColor = UIManager.getColor( "SearchField.searchIconColor" );
|
||||||
protected Color searchIconHoverColor = UIManager.getColor( "SearchField.searchIconHoverColor" );
|
@Styleable protected Color searchIconHoverColor = UIManager.getColor( "SearchField.searchIconHoverColor" );
|
||||||
protected Color searchIconPressedColor = UIManager.getColor( "SearchField.searchIconPressedColor" );
|
@Styleable protected Color searchIconPressedColor = UIManager.getColor( "SearchField.searchIconPressedColor" );
|
||||||
|
|
||||||
public FlatSearchIcon() {
|
public FlatSearchIcon() {
|
||||||
super( 16, 16, null );
|
super( 16, 16, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public Object applyStyleProperty( String key, Object value ) {
|
||||||
|
return FlatStyleSupport.applyToAnnotatedObject( this, key, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public Map<String, Class<?>> getStyleableInfos() {
|
||||||
|
return FlatStyleSupport.getAnnotatedStyleableInfos( this );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintIcon( Component c, Graphics2D g ) {
|
protected void paintIcon( Component c, Graphics2D g ) {
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -976,4 +976,33 @@ public class TestFlatStyling
|
|||||||
icon.applyStyleProperty( "questionMarkColor", Color.WHITE );
|
icon.applyStyleProperty( "questionMarkColor", Color.WHITE );
|
||||||
icon.applyStyleProperty( "disabledQuestionMarkColor", Color.WHITE );
|
icon.applyStyleProperty( "disabledQuestionMarkColor", Color.WHITE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatClearIcon() {
|
||||||
|
FlatClearIcon icon = new FlatClearIcon();
|
||||||
|
|
||||||
|
icon.applyStyleProperty( "clearIconColor", Color.WHITE );
|
||||||
|
icon.applyStyleProperty( "clearIconHoverColor", Color.WHITE );
|
||||||
|
icon.applyStyleProperty( "clearIconPressedColor", Color.WHITE );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatSearchIcon() {
|
||||||
|
FlatSearchIcon icon = new FlatSearchIcon();
|
||||||
|
|
||||||
|
flatSearchIcon( icon );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void flatSearchWithHistoryIcon() {
|
||||||
|
FlatSearchWithHistoryIcon icon = new FlatSearchWithHistoryIcon();
|
||||||
|
|
||||||
|
flatSearchIcon( icon );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void flatSearchIcon( FlatSearchIcon icon ) {
|
||||||
|
icon.applyStyleProperty( "searchIconColor", Color.WHITE );
|
||||||
|
icon.applyStyleProperty( "searchIconHoverColor", Color.WHITE );
|
||||||
|
icon.applyStyleProperty( "searchIconPressedColor", Color.WHITE );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user