01: /**********************************************************************************
02:
03: Feedzeo!
04: A free and open source RSS/Atom/RDF feed aggregator
05:
06: Copyright (C) 2005-2006 Anand Rao (anandrao@users.sourceforge.net)
07:
08: This library is free software; you can redistribute it and/or
09: modify it under the terms of the GNU Lesser General Public
10: License as published by the Free Software Foundation; either
11: version 2.1 of the License, or (at your option) any later version.
12:
13: This library is distributed in the hope that it will be useful,
14: but WITHOUT ANY WARRANTY; without even the implied warranty of
15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: Lesser General Public License for more details.
17:
18: You should have received a copy of the GNU Lesser General Public
19: License along with this library; if not, write to the Free Software
20: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21:
22: ************************************************************************************/package util;
23:
24: import org.jdesktop.jdic.tray.*;
25: import javax.swing.*;
26: import java.awt.*;
27: import java.awt.event.*;
28:
29: public class SysTrayItem {
30:
31: SystemTray tray = SystemTray.getDefaultSystemTray();
32: TrayIcon ti = null;
33:
34: public SysTrayItem(Icon i) {
35: ti = new TrayIcon(i);
36: ti.setIconAutoSize(true);
37: }
38:
39: public SysTrayItem(Icon i, String caption) {
40: ti = new TrayIcon(i, caption);
41: ti.setIconAutoSize(true);
42: }
43:
44: public SysTrayItem(Icon i, String caption, JPopupMenu popup) {
45: ti = new TrayIcon(i, caption, popup);
46: ti.setIconAutoSize(true);
47: }
48:
49: public void addActionListener(ActionListener a) {
50: ti.addActionListener(a);
51: }
52:
53: public void attachToSystemTray() {
54: if (ti != null)
55: tray.addTrayIcon(ti);
56: }
57:
58: public void detachFromSystemTray() {
59: if (ti != null)
60: tray.removeTrayIcon(ti);
61: }
62:
63: }
|