diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java index d8aa33a5..c43a25a1 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java @@ -202,13 +202,7 @@ public class FlatButtonUI @Override protected BasicButtonListener createButtonListener( AbstractButton b ) { - return new BasicButtonListener( b ) { - @Override - public void propertyChange( PropertyChangeEvent e ) { - super.propertyChange( e ); - FlatButtonUI.this.propertyChange( b, e ); - } - }; + return new FlatButtonListener( b ); } protected void propertyChange( AbstractButton b, PropertyChangeEvent e ) { @@ -475,4 +469,23 @@ public class FlatButtonUI return prefSize; } + + //---- class FlatButtonListener ------------------------------------------- + + protected class FlatButtonListener + extends BasicButtonListener + { + private final AbstractButton b; + + protected FlatButtonListener( AbstractButton b ) { + super( b ); + this.b = b; + } + + @Override + public void propertyChange( PropertyChangeEvent e ) { + super.propertyChange( e ); + FlatButtonUI.this.propertyChange( b, e ); + } + } } diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java index 2dca2a81..d435ecb7 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java @@ -119,7 +119,7 @@ public class FlatComboBoxUI protected Color buttonHoverArrowColor; private MouseListener hoverListener; - private boolean hover; + protected boolean hover; private WeakReference lastRendererComponent; @@ -332,14 +332,7 @@ public class FlatComboBoxUI @Override protected JButton createArrowButton() { - return new FlatArrowButton( SwingConstants.SOUTH, arrowType, buttonArrowColor, - buttonDisabledArrowColor, buttonHoverArrowColor, null ) - { - @Override - protected boolean isHover() { - return super.isHover() || (!comboBox.isEditable() ? hover : false); - } - }; + return new FlatComboBoxButton(); } @Override @@ -507,6 +500,27 @@ public class FlatComboBoxUI } } + //---- class FlatComboBoxButton ------------------------------------------- + + protected class FlatComboBoxButton + extends FlatArrowButton + { + protected FlatComboBoxButton() { + this( SwingConstants.SOUTH, arrowType, buttonArrowColor, buttonDisabledArrowColor, buttonHoverArrowColor, null, null ); + } + + protected FlatComboBoxButton( int direction, String type, Color foreground, Color disabledForeground, + Color hoverForeground, Color hoverBackground, Color pressedBackground ) + { + super( direction, type, foreground, disabledForeground, hoverForeground, hoverBackground, pressedBackground ); + } + + @Override + protected boolean isHover() { + return super.isHover() || (!comboBox.isEditable() ? hover : false); + } + } + //---- class FlatComboPopup ----------------------------------------------- @SuppressWarnings( { "rawtypes", "unchecked" } ) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java index 30596cf6..52695bbb 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameTitlePane.java @@ -150,7 +150,7 @@ public class FlatInternalFrameTitlePane //---- class FlatPropertyChangeHandler ------------------------------------ - private class FlatPropertyChangeHandler + protected class FlatPropertyChangeHandler extends PropertyChangeHandler { @Override diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java index 26571390..e5b71d8d 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java @@ -198,46 +198,12 @@ public class FlatScrollBarUI @Override protected JButton createDecreaseButton( int orientation ) { - return createArrowButton( orientation ); + return new FlatScrollBarButton( orientation ); } @Override protected JButton createIncreaseButton( int orientation ) { - return createArrowButton( orientation ); - } - - private JButton createArrowButton( int orientation ) { - FlatArrowButton button = new FlatArrowButton( orientation, arrowType, buttonArrowColor, - buttonDisabledArrowColor, null, hoverButtonBackground, pressedButtonBackground ) - { - @Override - protected Color deriveBackground( Color background ) { - return FlatUIUtils.deriveColor( background, scrollbar.getBackground() ); - } - - @Override - public Dimension getPreferredSize() { - if( isShowButtons() ) { - int w = UIScale.scale( scrollBarWidth ); - return new Dimension( w, w ); - } else - return new Dimension(); - } - - @Override - public Dimension getMinimumSize() { - return isShowButtons() ? super.getMinimumSize() : new Dimension(); - } - - @Override - public Dimension getMaximumSize() { - return isShowButtons() ? super.getMaximumSize() : new Dimension(); - } - }; - button.setArrowWidth( FlatArrowButton.DEFAULT_ARROW_WIDTH - 2 ); - button.setFocusable( false ); - button.setRequestFocusEnabled( false ); - return button; + return new FlatScrollBarButton( orientation ); } protected boolean isShowButtons() { @@ -377,4 +343,49 @@ public class FlatScrollBarUI scrollbar.repaint(); } } + + //---- class FlatScrollBarButton ------------------------------------------ + + protected class FlatScrollBarButton + extends FlatArrowButton + { + protected FlatScrollBarButton( int direction ) { + this( direction, arrowType, buttonArrowColor, buttonDisabledArrowColor, + null, hoverButtonBackground, pressedButtonBackground ); + } + + protected FlatScrollBarButton( int direction, String type, Color foreground, Color disabledForeground, + Color hoverForeground, Color hoverBackground, Color pressedBackground ) + { + super( direction, type, foreground, disabledForeground, hoverForeground, hoverBackground, pressedBackground ); + + setArrowWidth( FlatArrowButton.DEFAULT_ARROW_WIDTH - 2 ); + setFocusable( false ); + setRequestFocusEnabled( false ); + } + + @Override + protected Color deriveBackground( Color background ) { + return FlatUIUtils.deriveColor( background, scrollbar.getBackground() ); + } + + @Override + public Dimension getPreferredSize() { + if( isShowButtons() ) { + int w = UIScale.scale( scrollBarWidth ); + return new Dimension( w, w ); + } else + return new Dimension(); + } + + @Override + public Dimension getMinimumSize() { + return isShowButtons() ? super.getMinimumSize() : new Dimension(); + } + + @Override + public Dimension getMaximumSize() { + return isShowButtons() ? super.getMaximumSize() : new Dimension(); + } + } } diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java index 9ede9583..c3b33bca 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java @@ -87,10 +87,10 @@ public class FlatSplitPaneUI //---- class FlatSplitPaneDivider ----------------------------------------- - private class FlatSplitPaneDivider + protected class FlatSplitPaneDivider extends BasicSplitPaneDivider { - public FlatSplitPaneDivider( BasicSplitPaneUI ui ) { + protected FlatSplitPaneDivider( BasicSplitPaneUI ui ) { super( ui ); }