mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Button: disabled text
This commit is contained in:
@@ -16,11 +16,16 @@
|
||||
|
||||
package com.formdev.flatlaf.ui;
|
||||
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicButtonUI;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
/**
|
||||
* Provides the Flat LaF UI delegate for {@link javax.swing.JButton}.
|
||||
@@ -62,4 +67,20 @@ public class FlatButtonUI
|
||||
|
||||
paint( g, c );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintText( Graphics g, JComponent c, Rectangle textRect, String text ) {
|
||||
AbstractButton b = (AbstractButton) c;
|
||||
if( b.getModel().isEnabled() )
|
||||
super.paintText( g, c, textRect, text );
|
||||
else {
|
||||
// paint disabled text
|
||||
FontMetrics fm = SwingUtilities2.getFontMetrics( c, g );
|
||||
int mnemonicIndex = b.getDisplayedMnemonicIndex();
|
||||
g.setColor( UIManager.getColor( "Button.disabledText" ) );
|
||||
SwingUtilities2.drawStringUnderlineCharAt( c, g, text, mnemonicIndex,
|
||||
textRect.x + getTextShiftOffset(),
|
||||
textRect.y + fm.getAscent() + getTextShiftOffset() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ window=@background
|
||||
#---- Button ----
|
||||
|
||||
Button.background=4c5052
|
||||
Button.disabledText=777777
|
||||
|
||||
Button.startBorderColor=5e6060
|
||||
Button.endBorderColor=5e6060
|
||||
|
||||
@@ -45,6 +45,7 @@ window=@background
|
||||
#---- Button ----
|
||||
|
||||
Button.background=ffffff
|
||||
Button.disabledText=999999
|
||||
|
||||
Button.startBorderColor=bfbfbf
|
||||
Button.endBorderColor=b3b3b3
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#---- Button ----
|
||||
|
||||
Button.background=ffffff
|
||||
Button.disabledText=000088
|
||||
|
||||
Button.startBorderColor=ff0000
|
||||
Button.endBorderColor=0000ff
|
||||
|
||||
Reference in New Issue
Block a user