mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
displaying mnemonics fixed for IdeaTitledBorder
(actually they do not work here) (cherry picked from commit 591c2cf)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.intellij.ui.border;
|
||||
|
||||
import com.intellij.ui.TitledSeparator;
|
||||
import com.intellij.util.ui.DialogUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -20,19 +21,25 @@ public class IdeaTitledBorder extends TitledBorder {
|
||||
super(title);
|
||||
titledSeparator = new TitledSeparator(title);
|
||||
titledSeparator.setText(title);
|
||||
DialogUtil.registerMnemonic(titledSeparator.getLabel(), null);
|
||||
|
||||
this.outsideInsets = new Insets(insets.top, insets.left, insets.bottom, insets.right);
|
||||
|
||||
this.insideInsets = new Insets(TitledSeparator.BOTTOM_INSET, indent, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
super.setTitle(title);
|
||||
titledSeparator.setText(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
int labelX = x + outsideInsets.left;
|
||||
int labelY = y + outsideInsets.top;
|
||||
|
||||
TitledSeparator titledSeparator = getTitledSeparator(c);
|
||||
titledSeparator.setText(title);
|
||||
JLabel label = titledSeparator.getLabel();
|
||||
Dimension labelSize = label.getPreferredSize();
|
||||
label.setSize(labelSize);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.util.ui;
|
||||
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -66,7 +67,7 @@ public class DialogUtil{
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerMnemonic(JLabel label, JComponent target) {
|
||||
public static void registerMnemonic(JLabel label, @Nullable JComponent target) {
|
||||
registerMnemonic(label, target, UIUtil.MNEMONIC);
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ public class DialogUtil{
|
||||
* @param mn mnemonic char
|
||||
* @since 11.0
|
||||
*/
|
||||
public static void registerMnemonic(JLabel label, JComponent target, char mn) {
|
||||
public static void registerMnemonic(JLabel label, @Nullable JComponent target, char mn) {
|
||||
String text = label.getText();
|
||||
if (text != null) {
|
||||
final StringBuilder realText = new StringBuilder(text.length());
|
||||
|
||||
Reference in New Issue
Block a user