Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Aug 26, 2021
2 parents 9b794d3 + 17212bb commit ba24fe1
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions src/main/java/featurecat/lizzie/gui/ConfigDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,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;
Expand Down Expand Up @@ -110,9 +111,9 @@ public class ConfigDialog extends LizzieDialog {
private List<String> 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
Expand Down Expand Up @@ -252,7 +253,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);

Expand Down Expand Up @@ -654,17 +655,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);
Expand Down Expand Up @@ -1822,6 +1823,28 @@ protected void done() {
}
}

private class PanelWithToolTip extends JPanel {
public void add(JLabel label) {
super.add(label);
String text = label.getText();
String displayedText =
SwingUtilities.layoutCompoundLabel(
label,
label.getFontMetrics(label.getFont()),
text,
label.getIcon(),
label.getVerticalAlignment(),
label.getHorizontalAlignment(),
label.getVerticalTextPosition(),
label.getHorizontalTextPosition(),
label.getBounds(),
label.getBounds(),
label.getBounds(),
label.getIconTextGap());
if (displayedText != text) label.setToolTipText(text);
}
}

private String getEngineLine() {
String engineLine = "";
File engineFile = null;
Expand Down

0 comments on commit ba24fe1

Please sign in to comment.