diff --git a/src/main/java/featurecat/lizzie/gui/ConfigDialog.java b/src/main/java/featurecat/lizzie/gui/ConfigDialog.java index a0d50074e..f1cadcc4f 100644 --- a/src/main/java/featurecat/lizzie/gui/ConfigDialog.java +++ b/src/main/java/featurecat/lizzie/gui/ConfigDialog.java @@ -82,6 +82,7 @@ import javax.swing.ListCellRenderer; import javax.swing.SpinnerNumberModel; import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.border.Border; import javax.swing.event.ChangeEvent; @@ -113,9 +114,9 @@ public class ConfigDialog extends JDialog { private List fontList; private Theme theme; - public JPanel uiTab; - public JPanel themeTab; - public JPanel aboutTab; + public PanelWithToolTip uiTab; + public PanelWithToolTip themeTab; + public PanelWithToolTip aboutTab; public JButton okButton; // Engine Tab @@ -256,7 +257,7 @@ public void actionPerformed(ActionEvent e) { tabbedPane = new JTabbedPane(JTabbedPane.TOP); getContentPane().add(tabbedPane, BorderLayout.CENTER); - JPanel engineTab = new JPanel(); + PanelWithToolTip engineTab = new PanelWithToolTip(); tabbedPane.addTab(resourceBundle.getString("LizzieConfig.title.engine"), null, engineTab, null); engineTab.setLayout(null); @@ -658,17 +659,17 @@ protected DocumentFilter getDocumentFilter() { chkPrintEngineLog.setBounds(167, 425, 201, 23); engineTab.add(chkPrintEngineLog); - uiTab = new JPanel(); + uiTab = new PanelWithToolTip(); tabbedPane.addTab(resourceBundle.getString("LizzieConfig.title.ui"), null, uiTab, null); uiTab.setLayout(null); // Theme Tab - themeTab = new JPanel(); + themeTab = new PanelWithToolTip(); tabbedPane.addTab(resourceBundle.getString("LizzieConfig.title.theme"), null, themeTab, null); themeTab.setLayout(null); // About Tab - aboutTab = new JPanel(); + aboutTab = new PanelWithToolTip(); tabbedPane.addTab(resourceBundle.getString("LizzieConfig.title.about"), null, aboutTab, null); JLabel lblLizzieName = new JLabel("Lizzie " + Lizzie.lizzieVersion); @@ -1819,6 +1820,31 @@ protected void done() { } } + private class PanelWithToolTip extends JPanel { + public void add(JLabel label) { + 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()), + labelText, + label.getIcon(), + label.getVerticalAlignment(), + label.getHorizontalAlignment(), + label.getVerticalTextPosition(), + label.getHorizontalTextPosition(), + label.getBounds(), + label.getBounds(), + label.getBounds(), + label.getIconTextGap()); + label.setText(labelText); + if (displayedText != toolTipText) label.setToolTipText(toolTipText); + super.add(label); + } + } + private String getEngineLine() { String engineLine = ""; File engineFile = null;