From: Niki Roo Date: Mon, 27 Apr 2020 18:37:20 +0000 (+0200) Subject: fix check icon in menu X-Git-Tag: fanfix-swing-1.0.0~11 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=a3da7387cebc178d10fec5e6260825b5f0c47238;p=fanfix-swing.git fix check icon in menu --- diff --git a/src/be/nikiroo/fanfix_swing/gui/MainFrame.java b/src/be/nikiroo/fanfix_swing/gui/MainFrame.java index e63a5518..efd30006 100644 --- a/src/be/nikiroo/fanfix_swing/gui/MainFrame.java +++ b/src/be/nikiroo/fanfix_swing/gui/MainFrame.java @@ -8,7 +8,7 @@ import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.List; -import javax.swing.ImageIcon; +import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JMenu; @@ -25,9 +25,6 @@ import be.nikiroo.fanfix.bundles.StringIdGui; import be.nikiroo.fanfix.bundles.UiConfig; import be.nikiroo.fanfix_swing.gui.book.BookInfo; import be.nikiroo.fanfix_swing.gui.importer.ImporterFrame; -import be.nikiroo.fanfix_swing.images.IconGenerator; -import be.nikiroo.fanfix_swing.images.IconGenerator.Icon; -import be.nikiroo.fanfix_swing.images.IconGenerator.Size; import be.nikiroo.utils.Version; import be.nikiroo.utils.ui.ConfigEditor; @@ -161,10 +158,6 @@ public class MainFrame extends JFrame { } private JMenuBar createMenuBar() { - // TODO: use a correct checkmark image - final ImageIcon yesIcon = IconGenerator.get(Icon.clear, Size.x16); - final ImageIcon noIcon = IconGenerator.get(Icon.empty, Size.x16); - JMenuBar bar = new JMenuBar(); // FILE @@ -227,36 +220,38 @@ public class MainFrame extends JFrame { JMenu view = new JMenu("View"); view.setMnemonic(KeyEvent.VK_V); - final JMenuItem mnuListMode = new JMenuItem("Show thumbnails", - KeyEvent.VK_T); - mnuListMode.setIcon(books.isListMode() ? noIcon : yesIcon); + final JMenuItem mnuListMode = new JCheckBoxMenuItem("Show thumbnails"); + mnuListMode.setMnemonic(KeyEvent.VK_T); + mnuListMode.setSelected(!books.isListMode()); mnuListMode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { books.setListMode(!books.isListMode()); - mnuListMode.setIcon(books.isListMode() ? noIcon : yesIcon); + mnuListMode.setSelected(!books.isListMode()); } }); - final JMenuItem mnuSidePane = new JMenuItem("Show story browser", - KeyEvent.VK_B); - mnuSidePane.setIcon(sidePanel ? yesIcon : noIcon); + final JMenuItem mnuSidePane = new JCheckBoxMenuItem( + "Show story browser"); + mnuSidePane.setMnemonic(KeyEvent.VK_B); + mnuSidePane.setSelected(sidePanel); mnuSidePane.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setSidePanel(!sidePanel); - mnuSidePane.setIcon(sidePanel ? yesIcon : noIcon); + mnuSidePane.setSelected(sidePanel); } }); - final JMenuItem mnuDetailsPane = new JMenuItem("Show details panel", - KeyEvent.VK_D); - mnuDetailsPane.setIcon(detailsPanel ? yesIcon : noIcon); + final JMenuItem mnuDetailsPane = new JCheckBoxMenuItem( + "Show details panel"); + mnuDetailsPane.setMnemonic(KeyEvent.VK_D); + mnuDetailsPane.setSelected(detailsPanel); mnuDetailsPane.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setDetailsPanel(!detailsPanel); - mnuDetailsPane.setIcon(detailsPanel ? yesIcon : noIcon); + mnuDetailsPane.setSelected(detailsPanel); } });