Source Code Cross Referenced for WindowsSysTray.java in  » RSS-RDF » nntp-rss » org » methodize » nntprss » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » nntp rss » org.methodize.nntprss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.methodize.nntprss;
002:
003:        /* -----------------------------------------------------------
004:         * nntp//rss - a bridge between the RSS world and NNTP clients
005:         * Copyright (c) 2002, 2003 Jason Brome.  All Rights Reserved.
006:         *
007:         * email: nntprss@methodize.org
008:         * mail:  Methodize Solutions
009:         *        PO Box 3865
010:         *        Grand Central Station
011:         *        New York NY 10163
012:         * 
013:         * This file is part of nntp//rss
014:         * 
015:         * This class uses the SysTray for Java libraries,
016:         * distributed under the GNU LGPL.
017:         * Further information: http://www.eikon.tum.de/~tamas/
018:         * 
019:         * nntp//rss is free software; you can redistribute it 
020:         * and/or modify it under the terms of the GNU General 
021:         * Public License as published by the Free Software Foundation; 
022:         * either version 2 of the License, or (at your option) any 
023:         * later version.
024:         *
025:         * This program is distributed in the hope that it will be 
026:         * useful, but WITHOUT ANY WARRANTY; without even the implied 
027:         * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
028:         * PURPOSE.  See the GNU General Public License for more 
029:         * details.
030:         *
031:         * You should have received a copy of the GNU General Public 
032:         * License along with this program; if not, write to the 
033:         * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
034:         * Boston, MA  02111-1307  USA
035:         * ----------------------------------------------------- */
036:
037:        import java.awt.event.MouseEvent;
038:        import java.awt.event.MouseListener;
039:        import java.io.IOException;
040:        import java.util.Vector;
041:
042:        import javax.swing.JFrame;
043:        import javax.swing.JLabel;
044:        import javax.swing.JOptionPane;
045:
046:        import org.methodize.nntprss.util.AppConstants;
047:        import snoozesoft.systray4j.SysTrayMenu;
048:        import snoozesoft.systray4j.SysTrayMenuEvent;
049:        import snoozesoft.systray4j.SysTrayMenuIcon;
050:        import snoozesoft.systray4j.SysTrayMenuItem;
051:        import snoozesoft.systray4j.SysTrayMenuListener;
052:
053:        /**
054:         * @author Jason Brome <jason@methodize.org>
055:         * @version $Id: WindowsSysTray.java,v 1.1 2003/03/24 03:15:45 jasonbrome Exp $
056:         */
057:
058:        public class WindowsSysTray extends JFrame implements 
059:                SysTrayMenuListener {
060:
061:            private SysTrayMenu menu;
062:            private SysTrayMenuIcon nntpIcon;
063:
064:            private String adminURL = "http://127.0.0.1:7810/";
065:
066:            private static final String MENU_ABOUT_TEXT = "About nntp//rss...";
067:            private static final String MENU_ABOUT_CMD = "about";
068:            private static final String MENU_EXIT_TEXT = "Exit";
069:            private static final String MENU_EXIT_CMD = "exit";
070:            private static final String MENU_PROPERTIES_TEXT = "Properties";
071:            private static final String MENU_PROPERTIES_CMD = "properties";
072:            private static final String ICON_FILE = "nntprss.ico";
073:
074:            public WindowsSysTray() {
075:
076:                super ("nntp//rss");
077:
078:                nntpIcon = new SysTrayMenuIcon(ICON_FILE);
079:                nntpIcon.addSysTrayMenuListener(this );
080:
081:                SysTrayMenuItem itemCfg = new SysTrayMenuItem(
082:                        MENU_PROPERTIES_TEXT, MENU_PROPERTIES_CMD);
083:                itemCfg.setEnabled(false);
084:                itemCfg.addSysTrayMenuListener(this );
085:
086:                SysTrayMenuItem itemExit = new SysTrayMenuItem(MENU_EXIT_TEXT,
087:                        MENU_EXIT_CMD);
088:                itemExit.addSysTrayMenuListener(this );
089:
090:                SysTrayMenuItem itemAbout = new SysTrayMenuItem(
091:                        MENU_ABOUT_TEXT, MENU_ABOUT_CMD);
092:                itemAbout.addSysTrayMenuListener(this );
093:
094:                Vector items = new Vector();
095:                items.add(itemExit);
096:                items.add(SysTrayMenu.SEPARATOR);
097:                items.add(itemAbout);
098:                items.add(SysTrayMenu.SEPARATOR);
099:                items.add(itemCfg);
100:
101:                menu = new SysTrayMenu(nntpIcon, "nntp//rss v"
102:                        + AppConstants.VERSION + " starting...", items);
103:            }
104:
105:            public void showStarted() {
106:                menu.setToolTip("nntp//rss v" + AppConstants.VERSION);
107:                menu.getItem(MENU_PROPERTIES_TEXT).setEnabled(true);
108:            }
109:
110:            public void shutdown() {
111:                menu.setToolTip("nntp//rss v" + AppConstants.VERSION
112:                        + " shutting down...");
113:                menu.getItem(MENU_PROPERTIES_TEXT).setEnabled(false);
114:                menu.getItem(MENU_ABOUT_TEXT).setEnabled(false);
115:                menu.getItem(MENU_EXIT_TEXT).setEnabled(false);
116:            }
117:
118:            /**
119:             * @see snoozesoft.systray4j.SysTrayMenuListener#iconLeftClicked(SysTrayMenuEvent)
120:             */
121:            public void iconLeftClicked(SysTrayMenuEvent arg0) {
122:            }
123:
124:            /**
125:             * @see snoozesoft.systray4j.SysTrayMenuListener#iconLeftDoubleClicked(SysTrayMenuEvent)
126:             */
127:            public void iconLeftDoubleClicked(SysTrayMenuEvent arg0) {
128:                startBrowser(adminURL);
129:            }
130:
131:            private void startBrowser(String url) {
132:                try {
133:                    Process process = Runtime.getRuntime().exec(
134:                            new String[] { "cmd.exe", "/c", "start", "\"\"",
135:                                    "\"" + url + "\"" });
136:                    process.waitFor();
137:                    process.exitValue();
138:
139:                } catch (IOException ie) {
140:                } catch (InterruptedException ie) {
141:                }
142:            }
143:
144:            /**
145:             * @see snoozesoft.systray4j.SysTrayMenuListener#menuItemSelected(SysTrayMenuEvent)
146:             */
147:            public void menuItemSelected(SysTrayMenuEvent e) {
148:                if (e.getActionCommand().equals(MENU_ABOUT_CMD)) {
149:                    final JLabel url = new JLabel(
150:                            "<html><u><font color=blue>http://www.methodize.org/nntprss</font></u></html>");
151:                    url.addMouseListener(new MouseListener() {
152:                        /**
153:                         * @see java.awt.event.MouseListener#mouseClicked(MouseEvent)
154:                         */
155:                        public void mouseClicked(MouseEvent arg0) {
156:                            startBrowser("http://www.methodize.org/nntprss");
157:                        }
158:
159:                        public void mouseEntered(MouseEvent arg0) {
160:                            url
161:                                    .setText("<html><u><font color=red>http://www.methodize.org/nntprss</font></u></html>");
162:                        }
163:
164:                        public void mouseExited(MouseEvent arg0) {
165:                            url
166:                                    .setText("<html><u><font color=blue>http://www.methodize.org/nntprss</font></u></html>");
167:                        }
168:
169:                        public void mousePressed(MouseEvent arg0) {
170:                        }
171:
172:                        public void mouseReleased(MouseEvent arg0) {
173:                        }
174:
175:                    });
176:
177:                    Object[] message = new Object[] {
178:                            "nntp//rss v" + AppConstants.VERSION, url, "\n",
179:                            "Copyright (c) 2002, 2003 Jason Brome",
180:                            "Licensed under the GNU Public License\n" };
181:                    JOptionPane.showMessageDialog(this , message,
182:                            MENU_ABOUT_TEXT, JOptionPane.INFORMATION_MESSAGE);
183:                } else if (e.getActionCommand().equals(MENU_EXIT_CMD)) {
184:                    Object[] options = { "QUIT", "CANCEL" };
185:                    int option = JOptionPane.showOptionDialog(this ,
186:                            "Are you sure you want to quit?",
187:                            "nntp//rss - Warning", JOptionPane.DEFAULT_OPTION,
188:                            JOptionPane.WARNING_MESSAGE, null, options,
189:                            options[1]);
190:                    if (option == 0) {
191:                        System.exit(0);
192:                    }
193:                } else if (e.getActionCommand().equals(MENU_PROPERTIES_CMD)) {
194:                    startBrowser(adminURL);
195:                } else {
196:                    // Invalid command, should not happen
197:                    JOptionPane.showMessageDialog(this , e.getActionCommand());
198:                }
199:            }
200:
201:            /**
202:             * Returns the adminURL.
203:             * @return String
204:             */
205:            public String getAdminURL() {
206:                return adminURL;
207:            }
208:
209:            /**
210:             * Sets the adminURL.
211:             * @param adminURL The adminURL to set
212:             */
213:            public void setAdminURL(String adminURL) {
214:                this.adminURL = adminURL;
215:            }
216:
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.