diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatDesktopIconUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatDesktopIconUI.java index 5dda474e..f008aa8c 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatDesktopIconUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatDesktopIconUI.java @@ -16,10 +16,12 @@ package com.formdev.flatlaf.ui; +import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.EventQueue; +import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Insets; @@ -33,6 +35,7 @@ import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JComponent; +import javax.swing.JDesktopPane; import javax.swing.event.MouseInputAdapter; import javax.swing.event.MouseInputListener; import javax.swing.JLabel; @@ -229,6 +232,21 @@ public class FlatDesktopIconUI return getPreferredSize( c ); } + @Override + public void update( Graphics g, JComponent c ) { + if( c.isOpaque() ) { + // fill background with color derived from desktop pane + Color background = c.getBackground(); + JDesktopPane desktopPane = desktopIcon.getDesktopPane(); + g.setColor( (desktopPane != null) + ? FlatUIUtils.deriveColor( background, desktopPane.getBackground() ) + : background ); + g.fillRect( 0, 0, c.getWidth(), c.getHeight() ); + } + + paint( g, c ); + } + void updateDockIcon() { // use invoke later to make sure that components are updated when switching LaF EventQueue.invokeLater( () -> { diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties index adfabc08..3dcd9fd5 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties @@ -166,7 +166,7 @@ Desktop.background = #3E434C #---- DesktopIcon ---- -DesktopIcon.background = lighten($Desktop.background,10%) +DesktopIcon.background = lighten($Desktop.background,10%,derived) #---- InternalFrame ---- diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties index 340becb0..d7fbce53 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties @@ -172,7 +172,7 @@ Desktop.background = #E6EBF0 #---- DesktopIcon ---- -DesktopIcon.background = darken($Desktop.background,10%) +DesktopIcon.background = darken($Desktop.background,10%,derived) #---- HelpButton ---- diff --git a/flatlaf-extras/src/main/resources/com/formdev/flatlaf/extras/resources/DerivedColorKeys.properties b/flatlaf-extras/src/main/resources/com/formdev/flatlaf/extras/resources/DerivedColorKeys.properties index fb439e06..05d01807 100644 --- a/flatlaf-extras/src/main/resources/com/formdev/flatlaf/extras/resources/DerivedColorKeys.properties +++ b/flatlaf-extras/src/main/resources/com/formdev/flatlaf/extras/resources/DerivedColorKeys.properties @@ -88,6 +88,11 @@ ComboBox.buttonPressedArrowColor = ComboBox.buttonArrowColor Component.custom.borderColor = null +#---- HelpButton ---- + +DesktopIcon.background = Desktop.background + + #---- HelpButton ---- HelpButton.disabledBackground = HelpButton.background diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt index 317d0fa9..670e81d8 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt @@ -249,7 +249,7 @@ Desktop.minOnScreenInsets 3,3,3,3 javax.swing.plaf.InsetsUIResource [UI] #---- DesktopIcon ---- -DesktopIcon.background #555c68 javax.swing.plaf.ColorUIResource [UI] +DesktopIcon.background #555c68 com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse) DesktopIcon.border [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.FlatEmptyBorder [UI] DesktopIcon.closeIcon [lazy] 24,24 com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon [UI] DesktopIcon.closeSize 20,20 javax.swing.plaf.DimensionUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt index 899ee0ae..5de588ec 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt @@ -253,7 +253,7 @@ Desktop.minOnScreenInsets 3,3,3,3 javax.swing.plaf.InsetsUIResource [UI] #---- DesktopIcon ---- -DesktopIcon.background #c6d2dd javax.swing.plaf.ColorUIResource [UI] +DesktopIcon.background #c6d2dd com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse) DesktopIcon.border [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.FlatEmptyBorder [UI] DesktopIcon.closeIcon [lazy] 24,24 com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon [UI] DesktopIcon.closeSize 20,20 javax.swing.plaf.DimensionUIResource [UI] diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java index d4006a2c..683985ef 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java @@ -446,7 +446,9 @@ public class FlatTestFrame Color green = dark ? Color.green.darker() : Color.green; updateComponentsRecur( content, (c, type) -> { - if( type == "view" || type == "tab" || c instanceof JSlider ) { + if( type == "view" || type == "tab" || c instanceof JSlider || c instanceof JInternalFrame ) { + if( c instanceof JInternalFrame ) + c = ((JInternalFrame)c).getContentPane(); c.setForeground( explicit ? magenta : restoreColor ); c.setBackground( explicit ? orange : restoreColor ); } else { @@ -620,7 +622,7 @@ public class FlatTestFrame public static void updateComponentsRecur( Container container, BiConsumer action ) { for( Component c : container.getComponents() ) { - if( c instanceof JPanel || c instanceof JDesktopPane ) { + if( c instanceof JPanel ) { updateComponentsRecur( (Container) c, action ); continue; } @@ -639,6 +641,9 @@ public class FlatTestFrame if( tab != null ) action.accept( tab, "tab" ); } + } else if( c instanceof JDesktopPane ) { + for( JInternalFrame f : ((JDesktopPane)c).getAllFrames() ) + action.accept( f, null ); } if( c instanceof JToolBar )