Skip to content

Commit

Permalink
Merge featurecat#893 again for additional feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Aug 31, 2021
2 parents 6b9e5a4 + 6e4eeaf commit 37e5d66
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/featurecat/lizzie/gui/ConfigDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -1825,13 +1825,14 @@ protected void done() {

private class PanelWithToolTip extends JPanel {
public void add(JLabel label) {
super.add(label);
String text = label.getText();
String texts[] = label.getText().split("\n", 2);
String labelText = texts[0];
String toolTipText = (texts.length >= 2) ? texts[1] : labelText;
String displayedText =
SwingUtilities.layoutCompoundLabel(
label,
label.getFontMetrics(label.getFont()),
text,
labelText,
label.getIcon(),
label.getVerticalAlignment(),
label.getHorizontalAlignment(),
Expand All @@ -1841,7 +1842,9 @@ public void add(JLabel label) {
label.getBounds(),
label.getBounds(),
label.getIconTextGap());
if (displayedText != text) label.setToolTipText(text);
label.setText(labelText);
if (displayedText != toolTipText) label.setToolTipText(toolTipText);
super.add(label);
}
}

Expand Down

0 comments on commit 37e5d66

Please sign in to comment.