fixed color of links in HTML text

This commit is contained in:
Karl Tauber
2019-11-28 17:04:15 +01:00
parent 7b5a9d9949
commit a99ffd4821
8 changed files with 22 additions and 8 deletions

View File

@@ -9,6 +9,7 @@ FlatLaf Change Log
"FlatLaf". Use `UIManager.getLookAndFeel().getID().startsWith( "FlatLaf" )` to
check whether the current look and feel is FlatLaf.
- Fixed selection background of checkbox in table cell.
- Fixed color of links in HTML text.
- Fixed jittery submenu rendering on Mac. (issue #10)
- Button: Make button square if button text is "..." or a single character.
- ComboBox: Fixed issues with NetBeans `org.openide.awt.ColorComboBox`

View File

@@ -42,6 +42,7 @@ import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.basic.BasicLookAndFeel;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.text.html.HTMLEditorKit;
import com.formdev.flatlaf.util.SystemInfo;
import com.formdev.flatlaf.util.UIScale;
@@ -149,6 +150,9 @@ public abstract class FlatLaf
mnemonicListener = null;
}
// restore default link color
new HTMLEditorKit().getStyleSheet().addRule( "a { color: blue; }" );
if( base != null )
base.uninitialize();
@@ -217,6 +221,13 @@ public abstract class FlatLaf
if( useScreenMenuBar )
defaults.put( "MenuBarUI", aquaMenuBarUI );
// update link color in HTML text
Color linkColor = defaults.getColor( "Component.linkColor" );
if( linkColor != null ) {
new HTMLEditorKit().getStyleSheet().addRule(
String.format( "a { color: #%06x; }", linkColor.getRGB() & 0xffffff ) );
}
return defaults;
}

View File

@@ -122,6 +122,7 @@ Component.borderColor=#646464
Component.disabledBorderColor=#646464
Component.focusedBorderColor=#466d94
Component.focusColor=#3d6185
Component.linkColor=#589df6
#---- List ----

View File

@@ -124,6 +124,7 @@ Component.borderColor=#c4c4c4
Component.disabledBorderColor=#cfcfcf
Component.focusedBorderColor=#87afda
Component.focusColor=#97c3f3
Component.linkColor=#4a78c2
#---- HelpButton ----

View File

@@ -296,7 +296,7 @@ class OptionPanePanel
private JOptionPane optionPane;
ShowDialogLinkLabel() {
setText( "<html><a href=\"#\" color=\"#589df6\">Show dialog</a></html>" );
setText( "<html><a href=\"#\">Show dialog</a></html>" );
addMouseListener( new MouseAdapter() {
@Override

View File

@@ -784,7 +784,7 @@ public class FlatComponentsTest
"[]"));
//---- label3 ----
label3.setText("<html>JLabel HTML<br>Sample <b>content</b><br> <u>text</u></html>");
label3.setText("<html>JLabel HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a></html>");
panel3.add(label3, "cell 0 0");
//======== scrollPane15 ========
@@ -792,7 +792,7 @@ public class FlatComponentsTest
//---- editorPane6 ----
editorPane6.setContentType("text/html");
editorPane6.setText("JEditorPane HTML<br>Sample <b>content</b><br> <u>text</u>");
editorPane6.setText("JEditorPane HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a>");
scrollPane15.setViewportView(editorPane6);
}
panel3.add(scrollPane15, "cell 0 1,grow");
@@ -802,7 +802,7 @@ public class FlatComponentsTest
//---- textPane6 ----
textPane6.setContentType("text/html");
textPane6.setText("JTextPane HTML<br>Sample <b>content</b><br> <u>text</u>");
textPane6.setText("JTextPane HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a>");
scrollPane16.setViewportView(textPane6);
}
panel3.add(scrollPane16, "cell 0 2,grow");

View File

@@ -737,7 +737,7 @@ new FormModel {
"opaque": false
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "<html>JLabel HTML<br>Sample <b>content</b><br> <u>text</u></html>"
"text": "<html>JLabel HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a></html>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
@@ -746,7 +746,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JEditorPane" ) {
name: "editorPane6"
"contentType": "text/html"
"text": "JEditorPane HTML<br>Sample <b>content</b><br> <u>text</u>"
"text": "JEditorPane HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a>"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1,grow"
@@ -756,7 +756,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JTextPane" ) {
name: "textPane6"
"contentType": "text/html"
"text": "JTextPane HTML<br>Sample <b>content</b><br> <u>text</u>"
"text": "JTextPane HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a>"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2,grow"

View File

@@ -296,7 +296,7 @@ public class FlatOptionPaneTest
private JOptionPane optionPane;
ShowDialogLinkLabel() {
setText( "<html><a href=\"#\" color=\"#589df6\">Show dialog</a></html>" );
setText( "<html><a href=\"#\">Show dialog</a></html>" );
addMouseListener( new MouseAdapter() {
@Override