mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-202749 Missing mnemonics for labels
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaLaf;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -9,39 +10,25 @@ import javax.swing.plaf.basic.BasicLabelUI;
|
||||
import java.awt.*;
|
||||
|
||||
public class DarculaLabelUI extends BasicLabelUI {
|
||||
private static boolean isMnemonicHidden = true;
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "unused"})
|
||||
public static ComponentUI createUI(final JComponent c) {
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new DarculaLabelUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintEnabledText(final JLabel l, final Graphics g, final String s, final int textX, final int textY) {
|
||||
int mnemIndex = l.getDisplayedMnemonicIndex();
|
||||
if (isMnemonicHidden()) {
|
||||
mnemIndex = -1;
|
||||
}
|
||||
|
||||
protected void paintEnabledText(JLabel l, Graphics g, String s, int textX, int textY) {
|
||||
g.setColor(l.getForeground());
|
||||
SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemIndex, textX, textY);
|
||||
paintText(l, g, s, textX, textY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintDisabledText(final JLabel l, final Graphics g, final String s, final int textX, final int textY) {
|
||||
int mnemIndex = l.getDisplayedMnemonicIndex();
|
||||
if (isMnemonicHidden()) {
|
||||
mnemIndex = -1;
|
||||
}
|
||||
|
||||
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) {
|
||||
g.setColor(UIManager.getColor("Label.disabledForeground"));
|
||||
paintText(l, g, s, textX, textY);
|
||||
}
|
||||
|
||||
private static void paintText(JLabel l, Graphics g, String s, int textX, int textY) {
|
||||
int mnemIndex = DarculaLaf.isAltPressed() ? l.getDisplayedMnemonicIndex() : -1;
|
||||
SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemIndex, textX, textY);
|
||||
}
|
||||
|
||||
private static boolean isMnemonicHidden() {
|
||||
if (UIManager.getBoolean("Button.showMnemonics")) {
|
||||
isMnemonicHidden = false;
|
||||
}
|
||||
return isMnemonicHidden;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user