mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
JIDE: support JideLabel to fix wrong text colors in dark themes
This commit is contained in:
@@ -19,7 +19,7 @@ FlatLaf Change Log
|
||||
menu bar and main content. If enabled with `UIManager.put(
|
||||
"TitlePane.unifiedBackground", true );` then window title bar and menu bar
|
||||
use same background color as main content. (PR #268; issue #254)
|
||||
- JIDE Common Layer: Support `JideButton` and `JideToggleButton`.
|
||||
- JIDE Common Layer: Support `JideButton`, `JideLabel` and `JideToggleButton`.
|
||||
|
||||
#### Fixed bugs
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ This addon for FlatLaf adds support for **some**
|
||||
Following JIDE Common Layer components are currently supported by this addon:
|
||||
|
||||
- `JideButton`
|
||||
- `JideLabel`
|
||||
- `JidePopupMenu`
|
||||
- `JideTabbedPane`
|
||||
- `JideToggleButton`
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2021 FormDev Software GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.formdev.flatlaf.jideoss.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.jidesoft.plaf.LookAndFeelFactory;
|
||||
import com.jidesoft.plaf.basic.BasicJideLabelUI;
|
||||
|
||||
/**
|
||||
* Provides the Flat LaF UI delegate for {@link com.jidesoft.swing.JideLabel}.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatJideLabelUI
|
||||
extends BasicJideLabelUI
|
||||
{
|
||||
private Color disabledForeground;
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
// usually JIDE would invoke this in JideLabel.updateUI(),
|
||||
// but it does not because FlatLaf already has added the UI class to the UI defaults
|
||||
LookAndFeelFactory.installJideExtension();
|
||||
|
||||
return FlatUIUtils.createSharedUI( FlatJideLabelUI.class, FlatJideLabelUI::new );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults( JLabel c ) {
|
||||
super.installDefaults( c );
|
||||
|
||||
if( !defaults_initialized ) {
|
||||
disabledForeground = UIManager.getColor( "JideLabel.disabledForeground" );
|
||||
|
||||
defaults_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallDefaults( JLabel c ) {
|
||||
super.uninstallDefaults( c );
|
||||
defaults_initialized = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintEnabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
|
||||
int mnemIndex = FlatLaf.isShowMnemonics() ? l.getDisplayedMnemonicIndex() : -1;
|
||||
g.setColor( l.getForeground() );
|
||||
FlatUIUtils.drawStringUnderlineCharAt( l, g, s, mnemIndex, textX, textY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintDisabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
|
||||
int mnemIndex = FlatLaf.isShowMnemonics() ? l.getDisplayedMnemonicIndex() : -1;
|
||||
g.setColor( disabledForeground );
|
||||
FlatUIUtils.drawStringUnderlineCharAt( l, g, s, mnemIndex, textX, textY );
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
#---- UI delegates ----
|
||||
|
||||
JideButtonUI = com.formdev.flatlaf.jideoss.ui.FlatJideButtonUI
|
||||
JideLabelUI = com.formdev.flatlaf.jideoss.ui.FlatJideLabelUI
|
||||
JidePopupMenuUI = com.formdev.flatlaf.jideoss.ui.FlatJidePopupMenuUI
|
||||
JideTabbedPaneUI = com.formdev.flatlaf.jideoss.ui.FlatJideTabbedPaneUI
|
||||
RangeSliderUI = com.formdev.flatlaf.jideoss.ui.FlatRangeSliderUI
|
||||
@@ -43,6 +44,13 @@ JideButton.highlight = $Button.selectedBackground
|
||||
Button.disabledForeground = $Button.disabledText
|
||||
|
||||
|
||||
#---- JideLabel ----
|
||||
|
||||
JideLabel.background = $Label.background
|
||||
JideLabel.foreground = $Label.foreground
|
||||
JideLabel.disabledForeground = $Label.disabledForeground
|
||||
|
||||
|
||||
#---- JidePopup ----
|
||||
|
||||
Resizable.resizeBorder = 4,4,4,4,$PopupMenu.borderColor
|
||||
|
||||
@@ -460,6 +460,14 @@ JideButton.textIconGap [active] 4
|
||||
JideButtonUI com.formdev.flatlaf.jideoss.ui.FlatJideButtonUI
|
||||
|
||||
|
||||
#---- JideLabel ----
|
||||
|
||||
JideLabel.background #3c3f41 javax.swing.plaf.ColorUIResource [UI]
|
||||
JideLabel.disabledForeground #888888 javax.swing.plaf.ColorUIResource [UI]
|
||||
JideLabel.foreground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||
JideLabelUI com.formdev.flatlaf.jideoss.ui.FlatJideLabelUI
|
||||
|
||||
|
||||
#---- JidePopupMenu ----
|
||||
|
||||
JidePopupMenuUI com.formdev.flatlaf.jideoss.ui.FlatJidePopupMenuUI
|
||||
|
||||
@@ -465,6 +465,14 @@ JideButton.textIconGap [active] 4
|
||||
JideButtonUI com.formdev.flatlaf.jideoss.ui.FlatJideButtonUI
|
||||
|
||||
|
||||
#---- JideLabel ----
|
||||
|
||||
JideLabel.background #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
|
||||
JideLabel.disabledForeground #8c8c8c javax.swing.plaf.ColorUIResource [UI]
|
||||
JideLabel.foreground #000000 javax.swing.plaf.ColorUIResource [UI]
|
||||
JideLabelUI com.formdev.flatlaf.jideoss.ui.FlatJideLabelUI
|
||||
|
||||
|
||||
#---- JidePopupMenu ----
|
||||
|
||||
JidePopupMenuUI com.formdev.flatlaf.jideoss.ui.FlatJidePopupMenuUI
|
||||
|
||||
@@ -456,6 +456,14 @@ JideButton.textIconGap [active] 4
|
||||
JideButtonUI com.formdev.flatlaf.jideoss.ui.FlatJideButtonUI
|
||||
|
||||
|
||||
#---- JideLabel ----
|
||||
|
||||
JideLabel.background #ccffcc javax.swing.plaf.ColorUIResource [UI]
|
||||
JideLabel.disabledForeground #000088 javax.swing.plaf.ColorUIResource [UI]
|
||||
JideLabel.foreground #008800 javax.swing.plaf.ColorUIResource [UI]
|
||||
JideLabelUI com.formdev.flatlaf.jideoss.ui.FlatJideLabelUI
|
||||
|
||||
|
||||
#---- JidePopupMenu ----
|
||||
|
||||
JidePopupMenuUI com.formdev.flatlaf.jideoss.ui.FlatJidePopupMenuUI
|
||||
|
||||
@@ -77,10 +77,7 @@
|
||||
|
||||
#---- JideLabel ----
|
||||
|
||||
+ JideLabel.background [active] #f0f0f0 javax.swing.plaf.ColorUIResource [UI]
|
||||
+ JideLabel.font Segoe UI plain 12 javax.swing.plaf.FontUIResource [UI]
|
||||
+ JideLabel.foreground [active] #000000 javax.swing.plaf.ColorUIResource [UI]
|
||||
+ JideLabelUI com.jidesoft.plaf.basic.BasicJideLabelUI
|
||||
|
||||
|
||||
#---- JidePopup ----
|
||||
|
||||
@@ -77,10 +77,7 @@
|
||||
|
||||
#---- JideLabel ----
|
||||
|
||||
+ JideLabel.background [active] #f0f0f0 javax.swing.plaf.ColorUIResource [UI]
|
||||
+ JideLabel.font Segoe UI plain 12 javax.swing.plaf.FontUIResource [UI]
|
||||
+ JideLabel.foreground [active] #000000 javax.swing.plaf.ColorUIResource [UI]
|
||||
+ JideLabelUI com.jidesoft.plaf.basic.BasicJideLabelUI
|
||||
|
||||
|
||||
#---- JidePopup ----
|
||||
|
||||
@@ -88,8 +88,8 @@ public class FlatJideOssTest
|
||||
: SwingUtilities.HORIZONTAL;
|
||||
|
||||
frame.updateComponentsRecur( this, (c, type) -> {
|
||||
if( c instanceof JideButton )
|
||||
((JideButton)c).setOrientation( orientation );
|
||||
if( c instanceof Alignable )
|
||||
((Alignable)c).setOrientation( orientation );
|
||||
} );
|
||||
|
||||
revalidate();
|
||||
@@ -108,6 +108,8 @@ public class FlatJideOssTest
|
||||
frame.updateComponentsRecur( this, (c, type) -> {
|
||||
if( c instanceof JideButton )
|
||||
((JideButton)c).setIcon( icon );
|
||||
else if( c instanceof JideLabel )
|
||||
((JideLabel)c).setIcon( icon );
|
||||
} );
|
||||
|
||||
revalidate();
|
||||
@@ -155,6 +157,12 @@ public class FlatJideOssTest
|
||||
JToolBar toolBar4 = new JToolBar();
|
||||
JideToggleButton jideToggleButton10 = new JideToggleButton();
|
||||
JToggleButton toggleButton2 = new JToggleButton();
|
||||
JLabel jideLabelLabel = new JLabel();
|
||||
JideLabel jideLabel1 = new JideLabel();
|
||||
JideLabel jideLabel2 = new JideLabel();
|
||||
JLabel styledLabelLabel = new JLabel();
|
||||
StyledLabel styledLabel1 = new StyledLabel();
|
||||
StyledLabel styledLabel2 = new StyledLabel();
|
||||
|
||||
//======== this ========
|
||||
setLayout(new MigLayout(
|
||||
@@ -172,6 +180,8 @@ public class FlatJideOssTest
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]para" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- jidePopupLabel ----
|
||||
@@ -368,6 +378,32 @@ public class FlatJideOssTest
|
||||
toolBar4.add(toggleButton2);
|
||||
}
|
||||
add(toolBar4, "cell 1 6 3 1");
|
||||
|
||||
//---- jideLabelLabel ----
|
||||
jideLabelLabel.setText("JideLabel:");
|
||||
add(jideLabelLabel, "cell 0 7");
|
||||
|
||||
//---- jideLabel1 ----
|
||||
jideLabel1.setText("enabled");
|
||||
add(jideLabel1, "cell 1 7");
|
||||
|
||||
//---- jideLabel2 ----
|
||||
jideLabel2.setText("disabled");
|
||||
jideLabel2.setEnabled(false);
|
||||
add(jideLabel2, "cell 1 7");
|
||||
|
||||
//---- styledLabelLabel ----
|
||||
styledLabelLabel.setText("StyledLabel:");
|
||||
add(styledLabelLabel, "cell 0 8");
|
||||
|
||||
//---- styledLabel1 ----
|
||||
styledLabel1.setText("enabled");
|
||||
add(styledLabel1, "cell 1 8");
|
||||
|
||||
//---- styledLabel2 ----
|
||||
styledLabel2.setText("disabled");
|
||||
styledLabel2.setEnabled(false);
|
||||
add(styledLabel2, "cell 1 8");
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ new FormModel {
|
||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[][left][fill][fill][fill]"
|
||||
"$rowConstraints": "[][][]para[][][][]"
|
||||
"$rowConstraints": "[][][]para[][][][]para[][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
@@ -277,6 +277,44 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 6 3 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "jideLabelLabel"
|
||||
"text": "JideLabel:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 7"
|
||||
} )
|
||||
add( new FormComponent( "com.jidesoft.swing.JideLabel" ) {
|
||||
name: "jideLabel1"
|
||||
"text": "enabled"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 7"
|
||||
} )
|
||||
add( new FormComponent( "com.jidesoft.swing.JideLabel" ) {
|
||||
name: "jideLabel2"
|
||||
"text": "disabled"
|
||||
"enabled": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 7"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "styledLabelLabel"
|
||||
"text": "StyledLabel:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 8"
|
||||
} )
|
||||
add( new FormComponent( "com.jidesoft.swing.StyledLabel" ) {
|
||||
name: "styledLabel1"
|
||||
"text": "enabled"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 8"
|
||||
} )
|
||||
add( new FormComponent( "com.jidesoft.swing.StyledLabel" ) {
|
||||
name: "styledLabel2"
|
||||
"text": "disabled"
|
||||
"enabled": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 8"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 635, 500 )
|
||||
|
||||
@@ -328,6 +328,10 @@ JideButton.selectedBackground
|
||||
JideButton.shadow
|
||||
JideButton.textIconGap
|
||||
JideButtonUI
|
||||
JideLabel.background
|
||||
JideLabel.disabledForeground
|
||||
JideLabel.foreground
|
||||
JideLabelUI
|
||||
JidePopupMenuUI
|
||||
JideTabbedPane.background
|
||||
JideTabbedPane.contentBorderInsets
|
||||
|
||||
Reference in New Issue
Block a user