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)
| 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. |