mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-14 07:47:12 -06:00
hide label and button mnemonics on Mac (#4)
This commit is contained in:
@@ -5,6 +5,7 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
- Use new chevron arrows in "Flat Light" and "Flat Dark" themes, but keep
|
- Use new chevron arrows in "Flat Light" and "Flat Dark" themes, but keep
|
||||||
triangle arrows in "Flat IntelliJ" and "Flat Darcula" themes. (issue #7)
|
triangle arrows in "Flat IntelliJ" and "Flat Darcula" themes. (issue #7)
|
||||||
|
- Hide label and button mnemonics on Mac. (issue #4)
|
||||||
- If a JButton has an icon and no text, then it does not get a minimum width
|
- If a JButton has an icon and no text, then it does not get a minimum width
|
||||||
(usually 72 pixel) and the left and right insets are same as top/bottom insets
|
(usually 72 pixel) and the left and right insets are same as top/bottom insets
|
||||||
so that it becomes square (if the icon is square).
|
so that it becomes square (if the icon is square).
|
||||||
|
|||||||
@@ -429,4 +429,8 @@ public abstract class FlatLaf
|
|||||||
|
|
||||||
return strs;
|
return strs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isShowMnemonics() {
|
||||||
|
return !SystemInfo.IS_MAC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import javax.swing.UIManager;
|
|||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicButtonUI;
|
import javax.swing.plaf.basic.BasicButtonUI;
|
||||||
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the Flat LaF UI delegate for {@link javax.swing.JButton}.
|
* Provides the Flat LaF UI delegate for {@link javax.swing.JButton}.
|
||||||
@@ -203,7 +204,7 @@ public class FlatButtonUI
|
|||||||
|
|
||||||
static void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text, Color foreground ) {
|
static void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text, Color foreground ) {
|
||||||
FontMetrics fm = b.getFontMetrics( b.getFont() );
|
FontMetrics fm = b.getFontMetrics( b.getFont() );
|
||||||
int mnemonicIndex = b.getDisplayedMnemonicIndex();
|
int mnemonicIndex = FlatLaf.isShowMnemonics() ? b.getDisplayedMnemonicIndex() : -1;
|
||||||
|
|
||||||
g.setColor( foreground );
|
g.setColor( foreground );
|
||||||
FlatUIUtils.drawStringUnderlineCharAt( b, g, text, mnemonicIndex,
|
FlatUIUtils.drawStringUnderlineCharAt( b, g, text, mnemonicIndex,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import javax.swing.SwingUtilities;
|
|||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicLabelUI;
|
import javax.swing.plaf.basic.BasicLabelUI;
|
||||||
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,9 +72,16 @@ public class FlatLabelUI
|
|||||||
defaults_initialized = false;
|
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
|
@Override
|
||||||
protected void paintDisabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
|
protected void paintDisabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
|
||||||
int mnemIndex = l.getDisplayedMnemonicIndex();
|
int mnemIndex = FlatLaf.isShowMnemonics() ? l.getDisplayedMnemonicIndex() : -1;
|
||||||
g.setColor( disabledForeground );
|
g.setColor( disabledForeground );
|
||||||
FlatUIUtils.drawStringUnderlineCharAt( l, g, s, mnemIndex, textX, textY );
|
FlatUIUtils.drawStringUnderlineCharAt( l, g, s, mnemIndex, textX, textY );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import javax.swing.plaf.ComponentUI;
|
|||||||
import javax.swing.plaf.UIResource;
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.plaf.basic.BasicTabbedPaneUI;
|
import javax.swing.plaf.basic.BasicTabbedPaneUI;
|
||||||
import javax.swing.text.View;
|
import javax.swing.text.View;
|
||||||
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the Flat LaF UI delegate for {@link javax.swing.JTabbedPane}.
|
* Provides the Flat LaF UI delegate for {@link javax.swing.JTabbedPane}.
|
||||||
@@ -263,7 +264,7 @@ public class FlatTabbedPaneUI
|
|||||||
} else
|
} else
|
||||||
color = disabledForeground;
|
color = disabledForeground;
|
||||||
|
|
||||||
int mnemIndex = tabPane.getDisplayedMnemonicIndexAt( tabIndex );
|
int mnemIndex = FlatLaf.isShowMnemonics() ? tabPane.getDisplayedMnemonicIndexAt( tabIndex ) : -1;
|
||||||
|
|
||||||
g.setColor( color );
|
g.setColor( color );
|
||||||
FlatUIUtils.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex,
|
FlatUIUtils.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex,
|
||||||
|
|||||||
Reference in New Issue
Block a user