From 6d01d4ad9b439cd9b77a89013e0c099025a51ed4 Mon Sep 17 00:00:00 2001 From: nathan Date: Sat, 10 Nov 2018 23:55:03 +0100 Subject: [PATCH] Added method to get all menu entries from the system tray, in their raw form. (#9) --- src/dorkbox/systemTray/Menu.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/dorkbox/systemTray/Menu.java b/src/dorkbox/systemTray/Menu.java index 12e5dcd..4d52991 100644 --- a/src/dorkbox/systemTray/Menu.java +++ b/src/dorkbox/systemTray/Menu.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -352,7 +353,18 @@ class Menu extends MenuItem { } /** - * This removes a menu entry from the menu. + * @return a copy of all of the current menu entries. It is safe to modify any of the entries in this list without concerning yourself with synchronize. + */ + public + List getEntries() { + synchronized (menuEntries) { + // access on this object must be synchronized for object visibility + return Collections.unmodifiableList(new ArrayList(menuEntries)); + } + } + + /** + * This removes a menu entry from the menu. * * @param entry This is the menu entry to remove */