From 3e48d5862857e6ca196ac16f2529ef243a5fddca Mon Sep 17 00:00:00 2001 From: delvh Date: Mon, 23 Mar 2020 21:35:55 +0100 Subject: [PATCH] Added theme support for ContextMenu --- .../client/ui/container/ContextMenu.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/envoy/client/ui/container/ContextMenu.java b/src/main/java/envoy/client/ui/container/ContextMenu.java index facfe73..4624223 100755 --- a/src/main/java/envoy/client/ui/container/ContextMenu.java +++ b/src/main/java/envoy/client/ui/container/ContextMenu.java @@ -10,6 +10,7 @@ import java.util.Map; import javax.swing.*; +import envoy.client.data.Settings; import envoy.client.ui.Theme; /** @@ -60,7 +61,10 @@ public class ContextMenu extends JPopupMenu { * {@link ContextMenu} * @since Envoy v0.1-beta */ - public ContextMenu(Component parent) { setInvoker(parent); } + public ContextMenu(Component parent) { + setInvoker(parent); + setOpaque(true); + } /** * @param label the string that a UI may use to display as a title @@ -80,13 +84,23 @@ public class ContextMenu extends JPopupMenu { */ public ContextMenu(String label, Component parent, Map itemsWithActions, Map itemIcons, Map itemMnemonics) { - super(label); + this(label); setInvoker(parent); this.items = (itemsWithActions != null) ? itemsWithActions : items; this.icons = (itemIcons != null) ? itemIcons : icons; this.mnemonics = (itemMnemonics != null) ? itemMnemonics : mnemonics; } + /** + * @param label the string that a UI may use to display as a title for the + * pop-up menu. + * @since Envoy v0.1-beta + */ + public ContextMenu(String label) { + super(label); + setOpaque(true); + } + /** * Prepares the PopupMenu to be displayed. Should only be used once all map * values have been set. @@ -110,21 +124,16 @@ public class ContextMenu extends JPopupMenu { else // normal JMenuItem wanted item = new JMenuItem(text, icons.containsKey(text) ? icons.get(text) : null); item.addActionListener(action); + item.setOpaque(true); if (mnemonics.containsKey(text)) item.setMnemonic(mnemonics.get(text)); add(item); }); getInvoker().addMouseListener(getShowingListener()); + applyTheme(Settings.getInstance().getCurrentTheme()); built = true; return this; } - /** - * @param label the string that a UI may use to display as a title for the - * pop-up menu. - * @since Envoy v0.1-beta - */ - public ContextMenu(String label) { super(label); } - private MouseAdapter getShowingListener() { return new MouseAdapter() { @@ -240,7 +249,7 @@ public class ContextMenu extends JPopupMenu { * @since Envoy v0.1-beta */ protected void applyTheme(Theme theme) { - setBackground(theme.getInteractableBackgroundColor()); + setBackground(theme.getCellColor()); setForeground(theme.getTextColor()); } }