From e44212fc656edb03aa0403c3e27c9ef0eb4e6198 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 20 Dec 2019 18:36:25 +0100 Subject: [PATCH] fixed link color (in HTML text) in IntelliJ platform themes --- CHANGELOG.md | 5 ++ .../java/com/formdev/flatlaf/FlatLaf.java | 8 ++- .../com/formdev/flatlaf/IntelliJTheme.java | 8 +++ .../flatlaf/demo/MoreComponentsPanel.java | 49 +++++++++++++++++++ .../flatlaf/demo/MoreComponentsPanel.jfd | 42 ++++++++++++++++ 5 files changed, 110 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df739cde..02fe65bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ FlatLaf Change Log ================== +## Unreleased + +- Fixed link color (in HTML text) in IntelliJ platform themes. + + ## 0.22 - TextComponent: Support placeholder text that is displayed if text field is diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java index b1c99104..b93cb7d2 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java @@ -236,12 +236,16 @@ public abstract class FlatLaf if( useScreenMenuBar ) defaults.put( "MenuBarUI", aquaMenuBarUI ); + invokePostInitialization( defaults ); + + return defaults; + } + + void invokePostInitialization( UIDefaults defaults ) { if( postInitialization != null ) { postInitialization.accept( defaults ); postInitialization = null; } - - return defaults; } List> getLafClassesForDefaultsLoading() { diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java index 52368c27..0e1d5175 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java @@ -419,6 +419,9 @@ public class IntelliJTheme uiKeyMapping.put( "ComboBox.ArrowButton.iconColor", "ComboBox.buttonArrowColor" ); uiKeyMapping.put( "ComboBox.ArrowButton.nonEditableBackground", "ComboBox.buttonBackground" ); + // Link + uiKeyMapping.put( "Link.activeForeground", "Component.linkColor" ); + // ProgressBar uiKeyMapping.put( "ProgressBar.background", "" ); // ignore uiKeyMapping.put( "ProgressBar.foreground", "" ); // ignore @@ -492,9 +495,14 @@ public class IntelliJTheme public UIDefaults getDefaults() { UIDefaults defaults = super.getDefaults(); theme.applyProperties( defaults ); + super.invokePostInitialization( defaults ); return defaults; } + @Override + void invokePostInitialization( UIDefaults defaults ) { + } + @Override ArrayList> getLafClassesForDefaultsLoading() { ArrayList> lafClasses = new ArrayList<>(); diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.java index a6b00dec..d0a1b198 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.java @@ -69,7 +69,14 @@ class MoreComponentsPanel JToggleButton toggleButton7 = new JToggleButton(); JLabel scrollBarLabel = new JLabel(); JScrollBar scrollBar1 = new JScrollBar(); + JLabel label4 = new JLabel(); JScrollBar scrollBar4 = new JScrollBar(); + JPanel panel3 = new JPanel(); + JLabel label3 = new JLabel(); + JScrollPane scrollPane15 = new JScrollPane(); + JEditorPane editorPane6 = new JEditorPane(); + JScrollPane scrollPane16 = new JScrollPane(); + JTextPane textPane6 = new JTextPane(); JScrollBar scrollBar5 = new JScrollBar(); JScrollBar scrollBar6 = new JScrollBar(); JLabel separatorLabel = new JLabel(); @@ -211,11 +218,53 @@ class MoreComponentsPanel scrollBar1.setOrientation(Adjustable.HORIZONTAL); add(scrollBar1, "cell 1 1,growx"); + //---- label4 ---- + label4.setText("HTML:"); + add(label4, "cell 5 1"); + //---- scrollBar4 ---- scrollBar4.setOrientation(Adjustable.HORIZONTAL); scrollBar4.setEnabled(false); add(scrollBar4, "cell 1 2,growx"); + //======== panel3 ======== + { + panel3.setOpaque(false); + panel3.setLayout(new MigLayout( + "ltr,insets 0,hidemode 3", + // columns + "[]", + // rows + "[]" + + "[]" + + "[]")); + + //---- label3 ---- + label3.setText("JLabel HTML
Sample content
text with link"); + panel3.add(label3, "cell 0 0"); + + //======== scrollPane15 ======== + { + + //---- editorPane6 ---- + editorPane6.setContentType("text/html"); + editorPane6.setText("JEditorPane HTML
Sample content
text with link"); + scrollPane15.setViewportView(editorPane6); + } + panel3.add(scrollPane15, "cell 0 1,grow"); + + //======== scrollPane16 ======== + { + + //---- textPane6 ---- + textPane6.setContentType("text/html"); + textPane6.setText("JTextPane HTML
Sample content
text with link"); + scrollPane16.setViewportView(textPane6); + } + panel3.add(scrollPane16, "cell 0 2,grow"); + } + add(panel3, "cell 5 2 1 9,aligny top,growy 0"); + //---- scrollBar5 ---- scrollBar5.setOrientation(Adjustable.HORIZONTAL); scrollBar5.putClientProperty("JScrollBar.showButtons", true); diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.jfd index 4a146a0e..f533a270 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.jfd +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.jfd @@ -140,6 +140,12 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 1,growx" } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label4" + "text": "HTML:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 5 1" + } ) add( new FormComponent( "javax.swing.JScrollBar" ) { name: "scrollBar4" "orientation": 0 @@ -147,6 +153,42 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 2,growx" } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$columnConstraints": "[]" + "$rowConstraints": "[][][]" + "$layoutConstraints": "ltr,insets 0,hidemode 3" + } ) { + name: "panel3" + "opaque": false + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label3" + "text": "JLabel HTML
Sample content
text with link" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane15" + add( new FormComponent( "javax.swing.JEditorPane" ) { + name: "editorPane6" + "contentType": "text/html" + "text": "JEditorPane HTML
Sample content
text with link" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1,grow" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane16" + add( new FormComponent( "javax.swing.JTextPane" ) { + name: "textPane6" + "contentType": "text/html" + "text": "JTextPane HTML
Sample content
text with link" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2,grow" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 5 2 1 9,aligny top,growy 0" + } ) add( new FormComponent( "javax.swing.JScrollBar" ) { name: "scrollBar5" "orientation": 0