mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 15:07:11 -06:00
Styling: support styling any component property that has public getter and setter methods
This commit is contained in:
@@ -55,6 +55,7 @@ import javax.swing.RootPaneContainer;
|
|||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIDefaults;
|
import javax.swing.UIDefaults;
|
||||||
import javax.swing.UIDefaults.ActiveValue;
|
import javax.swing.UIDefaults.ActiveValue;
|
||||||
|
import javax.swing.UIDefaults.LazyValue;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
import javax.swing.plaf.ColorUIResource;
|
import javax.swing.plaf.ColorUIResource;
|
||||||
@@ -794,7 +795,16 @@ public abstract class FlatLaf
|
|||||||
public static Object parseDefaultsValue( String key, String value, Class<?> valueType )
|
public static Object parseDefaultsValue( String key, String value, Class<?> valueType )
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return UIDefaultsLoader.parseValue( key, value, valueType );
|
// parse value
|
||||||
|
Object val = UIDefaultsLoader.parseValue( key, value, valueType );
|
||||||
|
|
||||||
|
// create actual value if lazy or active
|
||||||
|
if( val instanceof LazyValue )
|
||||||
|
val = ((LazyValue)val).createValue( null );
|
||||||
|
else if( val instanceof ActiveValue )
|
||||||
|
val = ((ActiveValue)val).createValue( null );
|
||||||
|
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void reSetLookAndFeel() {
|
private static void reSetLookAndFeel() {
|
||||||
|
|||||||
@@ -391,9 +391,9 @@ class UIDefaultsLoader
|
|||||||
(key.endsWith( ".background" ) || key.endsWith( "Background" ) || key.equals( "background" ) ||
|
(key.endsWith( ".background" ) || key.endsWith( "Background" ) || key.equals( "background" ) ||
|
||||||
key.endsWith( ".foreground" ) || key.endsWith( "Foreground" ) || key.equals( "foreground" ))) )
|
key.endsWith( ".foreground" ) || key.endsWith( "Foreground" ) || key.equals( "foreground" ))) )
|
||||||
valueType = ValueType.COLOR;
|
valueType = ValueType.COLOR;
|
||||||
else if( key.endsWith( ".border" ) || key.endsWith( "Border" ) )
|
else if( key.endsWith( ".border" ) || key.endsWith( "Border" ) || key.equals( "border" ) )
|
||||||
valueType = ValueType.BORDER;
|
valueType = ValueType.BORDER;
|
||||||
else if( key.endsWith( ".icon" ) || key.endsWith( "Icon" ) )
|
else if( key.endsWith( ".icon" ) || key.endsWith( "Icon" ) || key.equals( "icon" ) )
|
||||||
valueType = ValueType.ICON;
|
valueType = ValueType.ICON;
|
||||||
else if( key.endsWith( ".margin" ) || key.equals( "margin" ) ||
|
else if( key.endsWith( ".margin" ) || key.equals( "margin" ) ||
|
||||||
key.endsWith( ".padding" ) || key.equals( "padding" ) ||
|
key.endsWith( ".padding" ) || key.equals( "padding" ) ||
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class FlatCheckBoxMenuItemUI
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
return FlatMenuItemUI.applyStyleProperty( this, key, value );
|
return FlatMenuItemUI.applyStyleProperty( this, menuItem, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class FlatEditorPaneUI
|
|||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, getComponent(), key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class FlatLabelUI
|
|||||||
public void installUI( JComponent c ) {
|
public void installUI( JComponent c ) {
|
||||||
super.installUI( c );
|
super.installUI( c );
|
||||||
|
|
||||||
applyStyle( FlatStylingSupport.getStyle( c ) );
|
applyStyle( (JLabel) c, FlatStylingSupport.getStyle( c ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -132,7 +132,7 @@ public class FlatLabelUI
|
|||||||
ui = (FlatLabelUI) c.getUI();
|
ui = (FlatLabelUI) c.getUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.applyStyle( style );
|
ui.applyStyle( c, style );
|
||||||
c.revalidate();
|
c.revalidate();
|
||||||
c.repaint();
|
c.repaint();
|
||||||
}
|
}
|
||||||
@@ -140,15 +140,16 @@ public class FlatLabelUI
|
|||||||
/**
|
/**
|
||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected void applyStyle( Object style ) {
|
protected void applyStyle( JLabel c, Object style ) {
|
||||||
oldStyleValues = FlatStylingSupport.parseAndApply( oldStyleValues, style, this::applyStyleProperty );
|
oldStyleValues = FlatStylingSupport.parseAndApply( oldStyleValues, style,
|
||||||
|
(key, value) -> applyStyleProperty( c, key, value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( JLabel c, String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, c, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ public class FlatListUI
|
|||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, list, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicMenuItemUI;
|
import javax.swing.plaf.basic.BasicMenuItemUI;
|
||||||
@@ -119,10 +120,10 @@ public class FlatMenuItemUI
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
return applyStyleProperty( this, key, value );
|
return applyStyleProperty( this, menuItem, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Object applyStyleProperty( BasicMenuItemUI ui, String key, Object value ) {
|
static Object applyStyleProperty( BasicMenuItemUI ui, JMenuItem menuItem, String key, Object value ) {
|
||||||
switch( key ) {
|
switch( key ) {
|
||||||
// BasicMenuItemUI
|
// BasicMenuItemUI
|
||||||
case "selectionBackground":
|
case "selectionBackground":
|
||||||
@@ -132,7 +133,8 @@ public class FlatMenuItemUI
|
|||||||
case "acceleratorSelectionForeground":
|
case "acceleratorSelectionForeground":
|
||||||
return FlatStylingSupport.applyToField( ui, key, key, value );
|
return FlatStylingSupport.applyToField( ui, key, key, value );
|
||||||
|
|
||||||
default: throw new UnknownStyleException( key );
|
default:
|
||||||
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( ui, menuItem, key, value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ public class FlatMenuUI
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
return FlatMenuItemUI.applyStyleProperty( this, key, value );
|
return FlatMenuItemUI.applyStyleProperty( this, menuItem, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public class FlatProgressBarUI
|
|||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, progressBar, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class FlatRadioButtonMenuItemUI
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
return FlatMenuItemUI.applyStyleProperty( this, key, value );
|
return FlatMenuItemUI.applyStyleProperty( this, menuItem, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class FlatRadioButtonUI
|
|||||||
public void installUI( JComponent c ) {
|
public void installUI( JComponent c ) {
|
||||||
super.installUI( c );
|
super.installUI( c );
|
||||||
|
|
||||||
applyStyle( FlatStylingSupport.getStyle( c ) );
|
applyStyle( (AbstractButton) c, FlatStylingSupport.getStyle( c ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -150,7 +150,7 @@ public class FlatRadioButtonUI
|
|||||||
ui = (FlatRadioButtonUI) b.getUI();
|
ui = (FlatRadioButtonUI) b.getUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.applyStyle( style );
|
ui.applyStyle( b, style );
|
||||||
b.revalidate();
|
b.revalidate();
|
||||||
b.repaint();
|
b.repaint();
|
||||||
}
|
}
|
||||||
@@ -158,14 +158,15 @@ public class FlatRadioButtonUI
|
|||||||
/**
|
/**
|
||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected void applyStyle( Object style ) {
|
protected void applyStyle( AbstractButton b, Object style ) {
|
||||||
oldStyleValues = FlatStylingSupport.parseAndApply( oldStyleValues, style, this::applyStyleProperty );
|
oldStyleValues = FlatStylingSupport.parseAndApply( oldStyleValues, style,
|
||||||
|
(key, value) -> applyStyleProperty( b, key, value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( AbstractButton b, String key, Object value ) {
|
||||||
// style icon
|
// style icon
|
||||||
if( key.startsWith( "icon." ) ) {
|
if( key.startsWith( "icon." ) ) {
|
||||||
if( !(icon instanceof FlatCheckBoxIcon) )
|
if( !(icon instanceof FlatCheckBoxIcon) )
|
||||||
@@ -180,7 +181,7 @@ public class FlatRadioButtonUI
|
|||||||
return ((FlatCheckBoxIcon)icon).applyStyleProperty( key, value );
|
return ((FlatCheckBoxIcon)icon).applyStyleProperty( key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, b, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ public class FlatScrollBarUI
|
|||||||
case "maximumThumbSize": oldValue = maximumThumbSize; maximumThumbSize = (Dimension) value; return oldValue;
|
case "maximumThumbSize": oldValue = maximumThumbSize; maximumThumbSize = (Dimension) value; return oldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, scrollbar, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class FlatSeparatorUI
|
|||||||
public void installUI( JComponent c ) {
|
public void installUI( JComponent c ) {
|
||||||
super.installUI( c );
|
super.installUI( c );
|
||||||
|
|
||||||
applyStyle( FlatStylingSupport.getStyle( c ) );
|
applyStyle( (JSeparator) c, FlatStylingSupport.getStyle( c ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -131,7 +131,7 @@ public class FlatSeparatorUI
|
|||||||
ui = (FlatSeparatorUI) s.getUI();
|
ui = (FlatSeparatorUI) s.getUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.applyStyle( style );
|
ui.applyStyle( s, style );
|
||||||
s.revalidate();
|
s.revalidate();
|
||||||
s.repaint();
|
s.repaint();
|
||||||
}
|
}
|
||||||
@@ -139,15 +139,16 @@ public class FlatSeparatorUI
|
|||||||
/**
|
/**
|
||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected void applyStyle( Object style ) {
|
protected void applyStyle( JSeparator s, Object style ) {
|
||||||
oldStyleValues = FlatStylingSupport.parseAndApply( oldStyleValues, style, this::applyStyleProperty );
|
oldStyleValues = FlatStylingSupport.parseAndApply( oldStyleValues, style,
|
||||||
|
(key, value) -> applyStyleProperty( s, key, value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( JSeparator s, String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, s, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class FlatSliderUI
|
|||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, slider, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public class FlatSplitPaneUI
|
|||||||
} catch( UnknownStyleException ex ) {
|
} catch( UnknownStyleException ex ) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, splitPane, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -81,7 +82,7 @@ public class FlatStylingSupport
|
|||||||
* @return map of old values modified by the given style, or {@code null}
|
* @return map of old values modified by the given style, or {@code null}
|
||||||
* @throws UnknownStyleException on unknown style keys
|
* @throws UnknownStyleException on unknown style keys
|
||||||
* @throws IllegalArgumentException on syntax errors
|
* @throws IllegalArgumentException on syntax errors
|
||||||
* @throws ClassCastException if value type does not fit to expected type
|
* @throws ClassCastException if value type does not fit to expected type
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> parseAndApply( Map<String, Object> oldStyleValues,
|
public static Map<String, Object> parseAndApply( Map<String, Object> oldStyleValues,
|
||||||
Object style, BiFunction<String, Object, Object> applyProperty )
|
Object style, BiFunction<String, Object, Object> applyProperty )
|
||||||
@@ -210,7 +211,7 @@ public class FlatStylingSupport
|
|||||||
* @param value the new value
|
* @param value the new value
|
||||||
* @return the old value of the field
|
* @return the old value of the field
|
||||||
* @throws UnknownStyleException if object does not have a annotated field with given name
|
* @throws UnknownStyleException if object does not have a annotated field with given name
|
||||||
* @throws IllegalArgumentException if value type does not fit to expected type
|
* @throws IllegalArgumentException if value type does not fit to expected type
|
||||||
*/
|
*/
|
||||||
public static Object applyToAnnotatedObject( Object obj, String key, Object value )
|
public static Object applyToAnnotatedObject( Object obj, String key, Object value )
|
||||||
throws UnknownStyleException, IllegalArgumentException
|
throws UnknownStyleException, IllegalArgumentException
|
||||||
@@ -239,7 +240,7 @@ public class FlatStylingSupport
|
|||||||
* @param value the new value
|
* @param value the new value
|
||||||
* @return the old value of the field
|
* @return the old value of the field
|
||||||
* @throws UnknownStyleException if object does not have a field with given name
|
* @throws UnknownStyleException if object does not have a field with given name
|
||||||
* @throws IllegalArgumentException if value type does not fit to expected type
|
* @throws IllegalArgumentException if value type does not fit to expected type
|
||||||
*/
|
*/
|
||||||
static Object applyToField( Object obj, String fieldName, String key, Object value )
|
static Object applyToField( Object obj, String fieldName, String key, Object value )
|
||||||
throws UnknownStyleException, IllegalArgumentException
|
throws UnknownStyleException, IllegalArgumentException
|
||||||
@@ -292,12 +293,90 @@ public class FlatStylingSupport
|
|||||||
return (modifiers & (Modifier.FINAL|Modifier.STATIC)) == 0 && !f.isSynthetic();
|
return (modifiers & (Modifier.FINAL|Modifier.STATIC)) == 0 && !f.isSynthetic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the given value to a property of the given object.
|
||||||
|
* Works only for properties that have public getter and setter methods.
|
||||||
|
* First the property getter is invoked to get the old value,
|
||||||
|
* then the property setter is invoked to set the new value.
|
||||||
|
*
|
||||||
|
* @param obj the object
|
||||||
|
* @param name the name of the property
|
||||||
|
* @param value the new value
|
||||||
|
* @return the old value of the property
|
||||||
|
* @throws UnknownStyleException if object does not have a property with given name
|
||||||
|
* @throws IllegalArgumentException if value type does not fit to expected type
|
||||||
|
*/
|
||||||
|
private static Object applyToProperty( Object obj, String name, Object value )
|
||||||
|
throws UnknownStyleException, IllegalArgumentException
|
||||||
|
{
|
||||||
|
Class<?> cls = obj.getClass();
|
||||||
|
String getterName = buildMethodName( "get", name );
|
||||||
|
String setterName = buildMethodName( "set", name );
|
||||||
|
|
||||||
|
try {
|
||||||
|
Method getter;
|
||||||
|
try {
|
||||||
|
getter = cls.getMethod( getterName );
|
||||||
|
} catch( NoSuchMethodException ex ) {
|
||||||
|
getter = cls.getMethod( buildMethodName( "is", name ) );
|
||||||
|
}
|
||||||
|
Method setter = cls.getMethod( setterName, getter.getReturnType() );
|
||||||
|
Object oldValue = getter.invoke( obj );
|
||||||
|
setter.invoke( obj, value );
|
||||||
|
return oldValue;
|
||||||
|
} catch( NoSuchMethodException ex ) {
|
||||||
|
throw new UnknownStyleException( name );
|
||||||
|
} catch( Exception ex ) {
|
||||||
|
throw new IllegalArgumentException( "failed to invoke property methods '" + cls.getName() + "."
|
||||||
|
+ getterName + "()' or '" + setterName + "(...)'", ex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String buildMethodName( String prefix, String name ) {
|
||||||
|
int prefixLength = prefix.length();
|
||||||
|
int nameLength = name.length();
|
||||||
|
char[] chars = new char[prefixLength + nameLength];
|
||||||
|
prefix.getChars( 0, prefixLength, chars, 0 );
|
||||||
|
name.getChars( 0, nameLength, chars, prefixLength );
|
||||||
|
chars[prefixLength] = Character.toUpperCase( chars[prefixLength] );
|
||||||
|
return new String( chars );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the given value to an annotated field of the given object
|
||||||
|
* or to a property of the given component.
|
||||||
|
* The field must be annotated with {@link Styleable}.
|
||||||
|
* The component property must have public getter and setter methods.
|
||||||
|
*
|
||||||
|
* @param obj the object
|
||||||
|
* @param comp the component, or {@code null}
|
||||||
|
* @param key the name of the field
|
||||||
|
* @param value the new value
|
||||||
|
* @return the old value of the field
|
||||||
|
* @throws UnknownStyleException if object does not have a annotated field with given name
|
||||||
|
* @throws IllegalArgumentException if value type does not fit to expected type
|
||||||
|
*/
|
||||||
|
public static Object applyToAnnotatedObjectOrComponent( Object obj, Object comp, String key, Object value ) {
|
||||||
|
try {
|
||||||
|
return applyToAnnotatedObject( obj, key, value );
|
||||||
|
} catch( UnknownStyleException ex ) {
|
||||||
|
try {
|
||||||
|
if( comp != null )
|
||||||
|
return applyToProperty( comp, key, value );
|
||||||
|
} catch( UnknownStyleException ex2 ) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Object applyToAnnotatedObjectOrBorder( Object obj, String key, Object value,
|
static Object applyToAnnotatedObjectOrBorder( Object obj, String key, Object value,
|
||||||
JComponent c, AtomicBoolean borderShared )
|
JComponent c, AtomicBoolean borderShared )
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return applyToAnnotatedObject( obj, key, value );
|
return applyToAnnotatedObject( obj, key, value );
|
||||||
} catch( UnknownStyleException ex ) {
|
} catch( UnknownStyleException ex ) {
|
||||||
|
// apply to border
|
||||||
Border border = c.getBorder();
|
Border border = c.getBorder();
|
||||||
if( border instanceof StyleableBorder ) {
|
if( border instanceof StyleableBorder ) {
|
||||||
if( borderShared.get() ) {
|
if( borderShared.get() ) {
|
||||||
@@ -312,6 +391,13 @@ public class FlatStylingSupport
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// apply to component property
|
||||||
|
try {
|
||||||
|
return applyToProperty( c, key, value );
|
||||||
|
} catch( UnknownStyleException ex2 ) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ public class FlatTabbedPaneUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, tabPane, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public class FlatTableHeaderUI
|
|||||||
if( key.equals( "sortIconPosition" ) && value instanceof String )
|
if( key.equals( "sortIconPosition" ) && value instanceof String )
|
||||||
value = parseSortIconPosition( (String) value );
|
value = parseSortIconPosition( (String) value );
|
||||||
|
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, header, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ public class FlatTableUI
|
|||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, table, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ public class FlatTextAreaUI
|
|||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, getComponent(), key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class FlatTextPaneUI
|
|||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, getComponent(), key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class FlatToolBarUI
|
|||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, toolBar, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ public class FlatTreeUI
|
|||||||
* @since TODO
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
protected Object applyStyleProperty( String key, Object value ) {
|
protected Object applyStyleProperty( String key, Object value ) {
|
||||||
return FlatStylingSupport.applyToAnnotatedObject( this, key, value );
|
return FlatStylingSupport.applyToAnnotatedObjectOrComponent( this, tree, key, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -131,6 +131,14 @@ public class TestFlatStyling
|
|||||||
|
|
||||||
// border
|
// border
|
||||||
flatButtonBorder( style -> ui.applyStyle( b, style ) );
|
flatButtonBorder( style -> ui.applyStyle( b, style ) );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( b, "background: #fff" );
|
||||||
|
ui.applyStyle( b, "foreground: #fff" );
|
||||||
|
ui.applyStyle( b, "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// AbstractButton properties
|
||||||
|
ui.applyStyle( b, "margin: 2,2,2,2" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -141,7 +149,7 @@ public class TestFlatStyling
|
|||||||
assertTrue( ui.getDefaultIcon() instanceof FlatCheckBoxIcon );
|
assertTrue( ui.getDefaultIcon() instanceof FlatCheckBoxIcon );
|
||||||
|
|
||||||
// FlatCheckBoxUI extends FlatRadioButtonUI
|
// FlatCheckBoxUI extends FlatRadioButtonUI
|
||||||
radioButton( ui );
|
radioButton( ui, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -175,6 +183,11 @@ public class TestFlatStyling
|
|||||||
|
|
||||||
// border
|
// border
|
||||||
flatRoundBorder( style -> ui.applyStyle( style ) );
|
flatRoundBorder( style -> ui.applyStyle( style ) );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -186,6 +199,17 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "disabledBackground: #fff" );
|
ui.applyStyle( "disabledBackground: #fff" );
|
||||||
ui.applyStyle( "inactiveBackground: #fff" );
|
ui.applyStyle( "inactiveBackground: #fff" );
|
||||||
ui.applyStyle( "focusedBackground: #fff" );
|
ui.applyStyle( "focusedBackground: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JTextComponent properties
|
||||||
|
ui.applyStyle( "caretColor: #fff" );
|
||||||
|
ui.applyStyle( "selectionColor: #fff" );
|
||||||
|
ui.applyStyle( "selectedTextColor: #fff" );
|
||||||
|
ui.applyStyle( "disabledTextColor: #fff" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -214,6 +238,11 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "inactiveDropShadowColor: #fff" );
|
ui.applyStyle( "inactiveDropShadowColor: #fff" );
|
||||||
ui.applyStyle( "inactiveDropShadowInsets: 1,2,3,4" );
|
ui.applyStyle( "inactiveDropShadowInsets: 1,2,3,4" );
|
||||||
ui.applyStyle( "inactiveDropShadowOpacity: 0.5" );
|
ui.applyStyle( "inactiveDropShadowOpacity: 0.5" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -221,7 +250,15 @@ public class TestFlatStyling
|
|||||||
JLabel c = new JLabel();
|
JLabel c = new JLabel();
|
||||||
FlatLabelUI ui = (FlatLabelUI) c.getUI();
|
FlatLabelUI ui = (FlatLabelUI) c.getUI();
|
||||||
|
|
||||||
ui.applyStyle( "disabledForeground: #fff" );
|
ui.applyStyle( c, "disabledForeground: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( c, "background: #fff" );
|
||||||
|
ui.applyStyle( c, "foreground: #fff" );
|
||||||
|
ui.applyStyle( c, "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JLabel properties
|
||||||
|
ui.applyStyle( c, "icon: com.formdev.flatlaf.icons.FlatTreeExpandedIcon" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -238,6 +275,14 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "cellMargins: 1,2,3,4" );
|
ui.applyStyle( "cellMargins: 1,2,3,4" );
|
||||||
ui.applyStyle( "cellFocusColor: #fff" );
|
ui.applyStyle( "cellFocusColor: #fff" );
|
||||||
ui.applyStyle( "showCellFocusIndicator: true" );
|
ui.applyStyle( "showCellFocusIndicator: true" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JList properties
|
||||||
|
ui.applyStyle( "visibleRowCount: 20" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -247,6 +292,11 @@ public class TestFlatStyling
|
|||||||
|
|
||||||
// FlatMenuBarBorder
|
// FlatMenuBarBorder
|
||||||
ui.applyStyle( "borderColor: #fff" );
|
ui.applyStyle( "borderColor: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -299,6 +349,14 @@ public class TestFlatStyling
|
|||||||
applyStyle.accept( "acceleratorSelectionForeground: #fff" );
|
applyStyle.accept( "acceleratorSelectionForeground: #fff" );
|
||||||
|
|
||||||
menuItemRenderer( applyStyle );
|
menuItemRenderer( applyStyle );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
applyStyle.accept( "background: #fff" );
|
||||||
|
applyStyle.accept( "foreground: #fff" );
|
||||||
|
applyStyle.accept( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// AbstractButton properties
|
||||||
|
applyStyle.accept( "margin: 2,2,2,2" );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void menuItemRenderer( Consumer<String> applyStyle ) {
|
private void menuItemRenderer( Consumer<String> applyStyle ) {
|
||||||
@@ -354,6 +412,11 @@ public class TestFlatStyling
|
|||||||
|
|
||||||
ui.applyStyle( "borderInsets: 1,2,3,4" );
|
ui.applyStyle( "borderInsets: 1,2,3,4" );
|
||||||
ui.applyStyle( "borderColor: #fff" );
|
ui.applyStyle( "borderColor: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -362,7 +425,7 @@ public class TestFlatStyling
|
|||||||
FlatPopupMenuSeparatorUI ui = (FlatPopupMenuSeparatorUI) c.getUI();
|
FlatPopupMenuSeparatorUI ui = (FlatPopupMenuSeparatorUI) c.getUI();
|
||||||
|
|
||||||
// FlatPopupMenuSeparatorUI extends FlatSeparatorUI
|
// FlatPopupMenuSeparatorUI extends FlatSeparatorUI
|
||||||
separator( ui );
|
separator( ui, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -373,6 +436,11 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "arc: 5" );
|
ui.applyStyle( "arc: 5" );
|
||||||
ui.applyStyle( "horizontalSize: 100,12" );
|
ui.applyStyle( "horizontalSize: 100,12" );
|
||||||
ui.applyStyle( "verticalSize: 12,100" );
|
ui.applyStyle( "verticalSize: 12,100" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -382,47 +450,55 @@ public class TestFlatStyling
|
|||||||
|
|
||||||
assertTrue( ui.getDefaultIcon() instanceof FlatRadioButtonIcon );
|
assertTrue( ui.getDefaultIcon() instanceof FlatRadioButtonIcon );
|
||||||
|
|
||||||
radioButton( ui );
|
radioButton( ui, c );
|
||||||
|
|
||||||
ui.applyStyle( "icon.centerDiameter: 8" );
|
ui.applyStyle( c, "icon.centerDiameter: 8" );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void radioButton( FlatRadioButtonUI ui ) {
|
private void radioButton( FlatRadioButtonUI ui, AbstractButton b ) {
|
||||||
ui.applyStyle( "disabledText: #fff" );
|
ui.applyStyle( b, "disabledText: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( b, "background: #fff" );
|
||||||
|
ui.applyStyle( b, "foreground: #fff" );
|
||||||
|
ui.applyStyle( b, "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// AbstractButton properties
|
||||||
|
ui.applyStyle( b, "margin: 2,2,2,2" );
|
||||||
|
|
||||||
//---- icon ----
|
//---- icon ----
|
||||||
|
|
||||||
ui.applyStyle( "icon.focusWidth: 2" );
|
ui.applyStyle( b, "icon.focusWidth: 2" );
|
||||||
ui.applyStyle( "icon.focusColor: #fff" );
|
ui.applyStyle( b, "icon.focusColor: #fff" );
|
||||||
ui.applyStyle( "icon.arc: 5" );
|
ui.applyStyle( b, "icon.arc: 5" );
|
||||||
|
|
||||||
// enabled
|
// enabled
|
||||||
ui.applyStyle( "icon.borderColor: #fff" );
|
ui.applyStyle( b, "icon.borderColor: #fff" );
|
||||||
ui.applyStyle( "icon.background: #fff" );
|
ui.applyStyle( b, "icon.background: #fff" );
|
||||||
ui.applyStyle( "icon.selectedBorderColor: #fff" );
|
ui.applyStyle( b, "icon.selectedBorderColor: #fff" );
|
||||||
ui.applyStyle( "icon.selectedBackground: #fff" );
|
ui.applyStyle( b, "icon.selectedBackground: #fff" );
|
||||||
ui.applyStyle( "icon.checkmarkColor: #fff" );
|
ui.applyStyle( b, "icon.checkmarkColor: #fff" );
|
||||||
|
|
||||||
// disabled
|
// disabled
|
||||||
ui.applyStyle( "icon.disabledBorderColor: #fff" );
|
ui.applyStyle( b, "icon.disabledBorderColor: #fff" );
|
||||||
ui.applyStyle( "icon.disabledBackground: #fff" );
|
ui.applyStyle( b, "icon.disabledBackground: #fff" );
|
||||||
ui.applyStyle( "icon.disabledCheckmarkColor: #fff" );
|
ui.applyStyle( b, "icon.disabledCheckmarkColor: #fff" );
|
||||||
|
|
||||||
// focused
|
// focused
|
||||||
ui.applyStyle( "icon.focusedBorderColor: #fff" );
|
ui.applyStyle( b, "icon.focusedBorderColor: #fff" );
|
||||||
ui.applyStyle( "icon.focusedBackground: #fff" );
|
ui.applyStyle( b, "icon.focusedBackground: #fff" );
|
||||||
ui.applyStyle( "icon.selectedFocusedBorderColor: #fff" );
|
ui.applyStyle( b, "icon.selectedFocusedBorderColor: #fff" );
|
||||||
ui.applyStyle( "icon.selectedFocusedBackground: #fff" );
|
ui.applyStyle( b, "icon.selectedFocusedBackground: #fff" );
|
||||||
ui.applyStyle( "icon.selectedFocusedCheckmarkColor: #fff" );
|
ui.applyStyle( b, "icon.selectedFocusedCheckmarkColor: #fff" );
|
||||||
|
|
||||||
// hover
|
// hover
|
||||||
ui.applyStyle( "icon.hoverBorderColor: #fff" );
|
ui.applyStyle( b, "icon.hoverBorderColor: #fff" );
|
||||||
ui.applyStyle( "icon.hoverBackground: #fff" );
|
ui.applyStyle( b, "icon.hoverBackground: #fff" );
|
||||||
ui.applyStyle( "icon.selectedHoverBackground: #fff" );
|
ui.applyStyle( b, "icon.selectedHoverBackground: #fff" );
|
||||||
|
|
||||||
// pressed
|
// pressed
|
||||||
ui.applyStyle( "icon.pressedBackground: #fff" );
|
ui.applyStyle( b, "icon.pressedBackground: #fff" );
|
||||||
ui.applyStyle( "icon.selectedPressedBackground: #fff" );
|
ui.applyStyle( b, "icon.selectedPressedBackground: #fff" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -454,6 +530,11 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "buttonDisabledArrowColor: #fff" );
|
ui.applyStyle( "buttonDisabledArrowColor: #fff" );
|
||||||
ui.applyStyle( "hoverButtonBackground: #fff" );
|
ui.applyStyle( "hoverButtonBackground: #fff" );
|
||||||
ui.applyStyle( "pressedButtonBackground: #fff" );
|
ui.applyStyle( "pressedButtonBackground: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -463,6 +544,11 @@ public class TestFlatStyling
|
|||||||
|
|
||||||
// border
|
// border
|
||||||
flatBorder( style -> ui.applyStyle( style ) );
|
flatBorder( style -> ui.applyStyle( style ) );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -470,13 +556,18 @@ public class TestFlatStyling
|
|||||||
JSeparator c = new JSeparator();
|
JSeparator c = new JSeparator();
|
||||||
FlatSeparatorUI ui = (FlatSeparatorUI) c.getUI();
|
FlatSeparatorUI ui = (FlatSeparatorUI) c.getUI();
|
||||||
|
|
||||||
separator( ui );
|
separator( ui, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void separator( FlatSeparatorUI ui ) {
|
private void separator( FlatSeparatorUI ui, JSeparator c ) {
|
||||||
ui.applyStyle( "height: 6" );
|
ui.applyStyle( c, "height: 6" );
|
||||||
ui.applyStyle( "stripeWidth: 2" );
|
ui.applyStyle( c, "stripeWidth: 2" );
|
||||||
ui.applyStyle( "stripeIndent: 10" );
|
ui.applyStyle( c, "stripeIndent: 10" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( c, "background: #fff" );
|
||||||
|
ui.applyStyle( c, "foreground: #fff" );
|
||||||
|
ui.applyStyle( c, "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -500,6 +591,17 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "disabledThumbColor: #fff" );
|
ui.applyStyle( "disabledThumbColor: #fff" );
|
||||||
ui.applyStyle( "disabledThumbBorderColor: #fff" );
|
ui.applyStyle( "disabledThumbBorderColor: #fff" );
|
||||||
ui.applyStyle( "tickColor: #fff" );
|
ui.applyStyle( "tickColor: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JSlider properties
|
||||||
|
ui.applyStyle( "paintLabels: true" );
|
||||||
|
ui.applyStyle( "paintTicks: true" );
|
||||||
|
ui.applyStyle( "paintTrack: true" );
|
||||||
|
ui.applyStyle( "snapToTicks: true" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -524,6 +626,11 @@ public class TestFlatStyling
|
|||||||
|
|
||||||
// border
|
// border
|
||||||
flatRoundBorder( style -> ui.applyStyle( style ) );
|
flatRoundBorder( style -> ui.applyStyle( style ) );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -541,6 +648,14 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "gripDotCount: 3" );
|
ui.applyStyle( "gripDotCount: 3" );
|
||||||
ui.applyStyle( "gripDotSize: {integer}3" );
|
ui.applyStyle( "gripDotSize: {integer}3" );
|
||||||
ui.applyStyle( "gripGap: 2" );
|
ui.applyStyle( "gripGap: 2" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JSplitPane properties
|
||||||
|
ui.applyStyle( "dividerSize: {integer}20" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -601,6 +716,11 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "closeHoverForeground: #fff" );
|
ui.applyStyle( "closeHoverForeground: #fff" );
|
||||||
ui.applyStyle( "closePressedBackground: #fff" );
|
ui.applyStyle( "closePressedBackground: #fff" );
|
||||||
ui.applyStyle( "closePressedForeground: #fff" );
|
ui.applyStyle( "closePressedForeground: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -617,6 +737,18 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "cellMargins: 1,2,3,4" );
|
ui.applyStyle( "cellMargins: 1,2,3,4" );
|
||||||
ui.applyStyle( "cellFocusColor: #fff" );
|
ui.applyStyle( "cellFocusColor: #fff" );
|
||||||
ui.applyStyle( "showCellFocusIndicator: true" );
|
ui.applyStyle( "showCellFocusIndicator: true" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JTable properties
|
||||||
|
ui.applyStyle( "fillsViewportHeight: true" );
|
||||||
|
ui.applyStyle( "rowHeight: 30" );
|
||||||
|
ui.applyStyle( "showHorizontalLines: true" );
|
||||||
|
ui.applyStyle( "showVerticalLines: true" );
|
||||||
|
ui.applyStyle( "intercellSpacing: {dimension}1,1" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -635,6 +767,11 @@ public class TestFlatStyling
|
|||||||
// FlatAscendingSortIcon and FlatDescendingSortIcon
|
// FlatAscendingSortIcon and FlatDescendingSortIcon
|
||||||
ui.applyStyle( "arrowType: chevron" );
|
ui.applyStyle( "arrowType: chevron" );
|
||||||
ui.applyStyle( "sortIconColor: #fff" );
|
ui.applyStyle( "sortIconColor: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -646,6 +783,17 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "disabledBackground: #fff" );
|
ui.applyStyle( "disabledBackground: #fff" );
|
||||||
ui.applyStyle( "inactiveBackground: #fff" );
|
ui.applyStyle( "inactiveBackground: #fff" );
|
||||||
ui.applyStyle( "focusedBackground: #fff" );
|
ui.applyStyle( "focusedBackground: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JTextComponent properties
|
||||||
|
ui.applyStyle( "caretColor: #fff" );
|
||||||
|
ui.applyStyle( "selectionColor: #fff" );
|
||||||
|
ui.applyStyle( "selectedTextColor: #fff" );
|
||||||
|
ui.applyStyle( "disabledTextColor: #fff" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -665,6 +813,17 @@ public class TestFlatStyling
|
|||||||
|
|
||||||
// border
|
// border
|
||||||
flatTextBorder( style -> ui.applyStyle( style ) );
|
flatTextBorder( style -> ui.applyStyle( style ) );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JTextComponent properties
|
||||||
|
ui.applyStyle( "caretColor: #fff" );
|
||||||
|
ui.applyStyle( "selectionColor: #fff" );
|
||||||
|
ui.applyStyle( "selectedTextColor: #fff" );
|
||||||
|
ui.applyStyle( "disabledTextColor: #fff" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -676,6 +835,17 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "disabledBackground: #fff" );
|
ui.applyStyle( "disabledBackground: #fff" );
|
||||||
ui.applyStyle( "inactiveBackground: #fff" );
|
ui.applyStyle( "inactiveBackground: #fff" );
|
||||||
ui.applyStyle( "focusedBackground: #fff" );
|
ui.applyStyle( "focusedBackground: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JTextComponent properties
|
||||||
|
ui.applyStyle( "caretColor: #fff" );
|
||||||
|
ui.applyStyle( "selectionColor: #fff" );
|
||||||
|
ui.applyStyle( "selectedTextColor: #fff" );
|
||||||
|
ui.applyStyle( "disabledTextColor: #fff" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -703,6 +873,17 @@ public class TestFlatStyling
|
|||||||
|
|
||||||
ui.applyStyle( "borderMargins: 1,2,3,4" );
|
ui.applyStyle( "borderMargins: 1,2,3,4" );
|
||||||
ui.applyStyle( "gripColor: #fff" );
|
ui.applyStyle( "gripColor: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JToolBar properties
|
||||||
|
ui.applyStyle( "borderPainted: true" );
|
||||||
|
ui.applyStyle( "floatable: true" );
|
||||||
|
ui.applyStyle( "margin: 2,2,2,2" );
|
||||||
|
ui.applyStyle( "rollover: true" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -734,6 +915,18 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "icon.leafColor: #fff" );
|
ui.applyStyle( "icon.leafColor: #fff" );
|
||||||
ui.applyStyle( "icon.closedColor: #fff" );
|
ui.applyStyle( "icon.closedColor: #fff" );
|
||||||
ui.applyStyle( "icon.openColor: #fff" );
|
ui.applyStyle( "icon.openColor: #fff" );
|
||||||
|
|
||||||
|
// JComponent properties
|
||||||
|
ui.applyStyle( "background: #fff" );
|
||||||
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
ui.applyStyle( "border: 2,2,2,2,#f00" );
|
||||||
|
|
||||||
|
// JTree properties
|
||||||
|
ui.applyStyle( "rootVisible: true" );
|
||||||
|
ui.applyStyle( "rowHeight: 30" );
|
||||||
|
ui.applyStyle( "scrollsOnExpand: true" );
|
||||||
|
ui.applyStyle( "showsRootHandles: true" );
|
||||||
|
ui.applyStyle( "visibleRowCount: 20" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- component borders --------------------------------------------------
|
//---- component borders --------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user