Styling: renamed client property JComponent.style to FlatLaf.style

This commit is contained in:
Karl Tauber
2021-06-19 11:14:33 +02:00
parent b4a9c9b7f5
commit ab4c9bdeda
11 changed files with 18 additions and 18 deletions

View File

@@ -134,7 +134,7 @@ public interface FlatClientProperties
* *
* @since TODO * @since TODO
*/ */
String COMPONENT_STYLE = "JComponent.style"; String STYLE = "FlatLaf.style";
/** /**
* Specifies minimum width of a component. * Specifies minimum width of a component.

View File

@@ -155,7 +155,7 @@ public class FlatEditorPaneUI
c.revalidate(); c.revalidate();
break; break;
case FlatClientProperties.COMPONENT_STYLE: case FlatClientProperties.STYLE:
applyStyle.accept( e.getNewValue() ); applyStyle.accept( e.getNewValue() );
c.revalidate(); c.revalidate();
c.repaint(); c.repaint();

View File

@@ -102,7 +102,7 @@ public class FlatProgressBarUI
progressBar.repaint(); progressBar.repaint();
break; break;
case COMPONENT_STYLE: case STYLE:
applyStyle( e.getNewValue() ); applyStyle( e.getNewValue() );
progressBar.revalidate(); progressBar.revalidate();
progressBar.repaint(); progressBar.repaint();

View File

@@ -131,7 +131,7 @@ public class FlatRadioButtonUI
*/ */
protected void propertyChange( AbstractButton b, PropertyChangeEvent e ) { protected void propertyChange( AbstractButton b, PropertyChangeEvent e ) {
switch( e.getPropertyName() ) { switch( e.getPropertyName() ) {
case FlatClientProperties.COMPONENT_STYLE: case FlatClientProperties.STYLE:
applyStyle( b, this, e.getNewValue() ); applyStyle( b, this, e.getNewValue() );
break; break;
} }

View File

@@ -193,7 +193,7 @@ public class FlatScrollBarUI
scrollbar.repaint(); scrollbar.repaint();
break; break;
case FlatClientProperties.COMPONENT_STYLE: case FlatClientProperties.STYLE:
applyStyle( e.getNewValue() ); applyStyle( e.getNewValue() );
scrollbar.revalidate(); scrollbar.revalidate();
scrollbar.repaint(); scrollbar.repaint();

View File

@@ -109,7 +109,7 @@ public class FlatSeparatorUI
propertyChangeListener = e -> { propertyChangeListener = e -> {
switch( e.getPropertyName() ) { switch( e.getPropertyName() ) {
case FlatClientProperties.COMPONENT_STYLE: case FlatClientProperties.STYLE:
applyStyle( s, this, e.getNewValue() ); applyStyle( s, this, e.getNewValue() );
s.revalidate(); s.revalidate();
s.repaint(); s.repaint();

View File

@@ -190,7 +190,7 @@ public class FlatSliderUI
superListener.propertyChange( e ); superListener.propertyChange( e );
switch( e.getPropertyName() ) { switch( e.getPropertyName() ) {
case FlatClientProperties.COMPONENT_STYLE: case FlatClientProperties.STYLE:
applyStyle( e.getNewValue() ); applyStyle( e.getNewValue() );
slider.revalidate(); slider.revalidate();
slider.repaint(); slider.repaint();

View File

@@ -119,7 +119,7 @@ public class FlatSplitPaneUI
propertyChangeListener = e -> { propertyChangeListener = e -> {
switch( e.getPropertyName() ) { switch( e.getPropertyName() ) {
case FlatClientProperties.COMPONENT_STYLE: case FlatClientProperties.STYLE:
applyStyle( e.getNewValue() ); applyStyle( e.getNewValue() );
splitPane.revalidate(); splitPane.revalidate();
splitPane.repaint(); splitPane.repaint();

View File

@@ -216,7 +216,7 @@ public class FlatStyleSupport
} }
public static Object getStyle( JComponent c ) { public static Object getStyle( JComponent c ) {
return c.getClientProperty( FlatClientProperties.COMPONENT_STYLE ); return c.getClientProperty( FlatClientProperties.STYLE );
} }
static Border cloneBorder( Border border ) { static Border cloneBorder( Border border ) {

View File

@@ -182,7 +182,7 @@ public class FlatTextFieldUI
c.revalidate(); c.revalidate();
break; break;
case FlatClientProperties.COMPONENT_STYLE: case FlatClientProperties.STYLE:
applyStyle.accept( e.getNewValue() ); applyStyle.accept( e.getNewValue() );
c.revalidate(); c.revalidate();
c.repaint(); c.repaint();

View File

@@ -17,7 +17,7 @@
package com.formdev.flatlaf.ui; package com.formdev.flatlaf.ui;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static com.formdev.flatlaf.FlatClientProperties.COMPONENT_STYLE; import static com.formdev.flatlaf.FlatClientProperties.STYLE;
import java.util.function.Supplier; import java.util.function.Supplier;
import javax.swing.JEditorPane; import javax.swing.JEditorPane;
import javax.swing.JFormattedTextField; import javax.swing.JFormattedTextField;
@@ -131,7 +131,7 @@ public class FlatTextComponentTests
String style1 = "inactiveBackground: #00ee00; disabledBackground: #0000ee"; String style1 = "inactiveBackground: #00ee00; disabledBackground: #0000ee";
String style2 = "inactiveBackground: #00dd00; disabledBackground: #0000dd"; String style2 = "inactiveBackground: #00dd00; disabledBackground: #0000dd";
c.putClientProperty( COMPONENT_STYLE, style1 ); c.putClientProperty( STYLE, style1 );
assertEquals( background, c.getBackground() ); assertEquals( background, c.getBackground() );
c.setEditable( false ); assertEquals( inactiveBackground1, c.getBackground() ); c.setEditable( false ); assertEquals( inactiveBackground1, c.getBackground() );
@@ -139,23 +139,23 @@ public class FlatTextComponentTests
c.setEditable( true ); assertEquals( disabledBackground1, c.getBackground() ); c.setEditable( true ); assertEquals( disabledBackground1, c.getBackground() );
c.setEnabled( true ); assertEquals( background, c.getBackground() ); c.setEnabled( true ); assertEquals( background, c.getBackground() );
c.putClientProperty( COMPONENT_STYLE, null ); c.putClientProperty( STYLE, null );
assertEquals( background, c.getBackground() ); assertEquals( background, c.getBackground() );
c.setEditable( false ); c.setEditable( false );
c.putClientProperty( COMPONENT_STYLE, style1 ); c.putClientProperty( STYLE, style1 );
assertEquals( inactiveBackground1, c.getBackground() ); assertEquals( inactiveBackground1, c.getBackground() );
c.putClientProperty( COMPONENT_STYLE, null ); c.putClientProperty( STYLE, null );
assertEquals( inactiveBackground, c.getBackground() ); assertEquals( inactiveBackground, c.getBackground() );
c.setEnabled( false ); c.setEnabled( false );
c.putClientProperty( COMPONENT_STYLE, style1 ); c.putClientProperty( STYLE, style1 );
assertEquals( disabledBackground1, c.getBackground() ); assertEquals( disabledBackground1, c.getBackground() );
// change from style1 to style2 // change from style1 to style2
c.putClientProperty( COMPONENT_STYLE, style2 ); c.putClientProperty( STYLE, style2 );
assertEquals( disabledBackground2, c.getBackground() ); assertEquals( disabledBackground2, c.getBackground() );
c.setEnabled( true ); c.setEnabled( true );
@@ -163,7 +163,7 @@ public class FlatTextComponentTests
// remove style // remove style
c.putClientProperty( COMPONENT_STYLE, null ); c.putClientProperty( STYLE, null );
assertEquals( inactiveBackground, c.getBackground() ); assertEquals( inactiveBackground, c.getBackground() );
} }
} }