MCPcopy Create free account
hub / github.com/dorkbox/SystemTray / setStatus

Method setStatus

src/dorkbox/systemTray/Tray.java:59–93  ·  view source on GitHub ↗

Sets a 'status' string at the first position in the popup menu. This 'status' string appears as a disabled menu entry. @param statusText the text you want displayed, null if you want to remove the 'status' text

(final String statusText)

Source from the content-addressed store, hash-verified

57 * @param statusText the text you want displayed, null if you want to remove the 'status' text
58 */
59 public
60 void setStatus(final String statusText) {
61 this.statusText = statusText;
62
63 // status is ALWAYS at 0 index...
64 Entry menuEntry = null;
65
66 synchronized (menuEntries) {
67 // access on this object must be synchronized for object visibility
68 if (!menuEntries.isEmpty()) {
69 menuEntry = menuEntries.get(0);
70 }
71 }
72
73 if (menuEntry instanceof Status) {
74 // set the text or delete...
75
76 if (statusText == null) {
77 // delete
78 remove(menuEntry);
79 }
80 else {
81 // set text
82 ((Status) menuEntry).setText(statusText);
83 }
84 } else {
85 // create a new one
86 Status status = new Status();
87 status.setText(statusText);
88
89 // status is ALWAYS at 0 index...
90 // also calls the hook to add it, so we don't need anything special
91 add(status, 0);
92 }
93 }
94
95 /**
96 * Specifies the new image to set for the tray icon.

Callers 5

TestMultiTrayMethod · 0.45
TestTrayMethod · 0.45
TestReAddTrayMethod · 0.45
TestTraySwtMethod · 0.45
doJavaFxStuffMethod · 0.45

Calls 5

removeMethod · 0.95
setTextMethod · 0.95
setTextMethod · 0.65
addMethod · 0.65
getMethod · 0.45

Tested by 5

TestMultiTrayMethod · 0.36
TestTrayMethod · 0.36
TestReAddTrayMethod · 0.36
TestTraySwtMethod · 0.36
doJavaFxStuffMethod · 0.36