mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 05:50:53 +03:00
JIDE: support JideLabel to fix wrong text colors in dark themes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user