Source Code Cross Referenced for SystemPropertiesPanel.java in  » Graphic-Library » jcommon-components » org » jfree » ui » about » 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 » Graphic Library » jcommon components » org.jfree.ui.about 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ========================================================================
002:         * JCommon : a free general purpose class library for the Java(tm) platform
003:         * ========================================================================
004:         *
005:         * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006:         * 
007:         * Project Info:  http://www.jfree.org/jcommon/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         * 
027:         * --------------------------
028:         * SystemPropertiesPanel.java
029:         * --------------------------
030:         * (C) Copyright 2001-2004, by Object Refinery Limited.
031:         *
032:         * Original Author:  David Gilbert (for Object Refinery Limited);
033:         * Contributor(s):   -;
034:         *
035:         * $Id: SystemPropertiesPanel.java,v 1.4 2005/10/18 13:19:13 mungady Exp $
036:         *
037:         * Changes
038:         * -------
039:         * 26-Nov-2001 : Version 1 (DG);
040:         * 28-Feb-2002 : Changed package to com.jrefinery.ui.about (DG);
041:         * 04-Mar-2002 : Added popup menu code by Carl ?? (DG);
042:         * 15-Mar-2002 : Modified to use ResourceBundle for elements that require localisation (DG);
043:         * 26-Jun-2002 : Removed unnecessary import (DG);
044:         * 08-Oct-2002 : Fixed errors reported by Checkstyle (DG);
045:         *
046:         */
047:
048:        package org.jfree.ui.about;
049:
050:        import java.awt.BorderLayout;
051:        import java.awt.Toolkit;
052:        import java.awt.datatransfer.Clipboard;
053:        import java.awt.datatransfer.StringSelection;
054:        import java.awt.event.ActionEvent;
055:        import java.awt.event.ActionListener;
056:        import java.awt.event.MouseAdapter;
057:        import java.awt.event.MouseEvent;
058:        import java.util.ResourceBundle;
059:
060:        import javax.swing.JMenuItem;
061:        import javax.swing.JPanel;
062:        import javax.swing.JPopupMenu;
063:        import javax.swing.JScrollPane;
064:        import javax.swing.JTable;
065:        import javax.swing.KeyStroke;
066:        import javax.swing.ListSelectionModel;
067:
068:        /**
069:         * A panel containing a table of system properties.
070:         *
071:         * @author David Gilbert
072:         */
073:        public class SystemPropertiesPanel extends JPanel {
074:
075:            /** The table that displays the system properties. */
076:            private JTable table;
077:
078:            /** Allows for a popup menu for copying. */
079:            private JPopupMenu copyPopupMenu;
080:
081:            /** A copy menu item. */
082:            private JMenuItem copyMenuItem;
083:
084:            /** A popup listener. */
085:            private PopupListener copyPopupListener;
086:
087:            /**
088:             * Constructs a new panel.
089:             */
090:            public SystemPropertiesPanel() {
091:
092:                final String baseName = "org.jfree.ui.about.resources.AboutResources";
093:                final ResourceBundle resources = ResourceBundle
094:                        .getBundle(baseName);
095:
096:                setLayout(new BorderLayout());
097:                this .table = SystemProperties.createSystemPropertiesTable();
098:                add(new JScrollPane(this .table));
099:
100:                // Add a popup menu to copy to the clipboard...
101:                this .copyPopupMenu = new JPopupMenu();
102:
103:                final String label = resources
104:                        .getString("system-properties-panel.popup-menu.copy");
105:                final KeyStroke accelerator = (KeyStroke) resources
106:                        .getObject("system-properties-panel.popup-menu.copy.accelerator");
107:                this .copyMenuItem = new JMenuItem(label);
108:                this .copyMenuItem.setAccelerator(accelerator);
109:                this .copyMenuItem.getAccessibleContext()
110:                        .setAccessibleDescription(label);
111:                this .copyMenuItem.addActionListener(new ActionListener() {
112:                    public void actionPerformed(final ActionEvent e) {
113:                        copySystemPropertiesToClipboard();
114:                    }
115:                });
116:                this .copyPopupMenu.add(this .copyMenuItem);
117:
118:                // add popup Listener to the table
119:                this .copyPopupListener = new PopupListener();
120:                this .table.addMouseListener(this .copyPopupListener);
121:
122:            }
123:
124:            /**
125:             * Copies the selected cells in the table to the clipboard, in tab-delimited format.
126:             */
127:            public void copySystemPropertiesToClipboard() {
128:
129:                final StringBuffer buffer = new StringBuffer();
130:                final ListSelectionModel selection = this .table
131:                        .getSelectionModel();
132:                final int firstRow = selection.getMinSelectionIndex();
133:                final int lastRow = selection.getMaxSelectionIndex();
134:                if ((firstRow != -1) && (lastRow != -1)) {
135:                    for (int r = firstRow; r <= lastRow; r++) {
136:                        for (int c = 0; c < this .table.getColumnCount(); c++) {
137:                            buffer.append(this .table.getValueAt(r, c));
138:                            if (c != 2) {
139:                                buffer.append("\t");
140:                            }
141:                        }
142:                        buffer.append("\n");
143:                    }
144:                }
145:                final StringSelection ss = new StringSelection(buffer
146:                        .toString());
147:                final Clipboard cb = Toolkit.getDefaultToolkit()
148:                        .getSystemClipboard();
149:                cb.setContents(ss, ss);
150:
151:            }
152:
153:            /**
154:             * Returns the copy popup menu.
155:             *
156:             * @return Returns the copyPopupMenu.
157:             */
158:            protected final JPopupMenu getCopyPopupMenu() {
159:                return copyPopupMenu;
160:            }
161:
162:            /**
163:             * Returns the table containing the system properties.
164:             * @return Returns the table.
165:             */
166:            protected final JTable getTable() {
167:                return table;
168:            }
169:
170:            /**
171:             * A popup listener.
172:             */
173:            private class PopupListener extends MouseAdapter {
174:
175:                /**
176:                 * Default constructor.
177:                 */
178:                public PopupListener() {
179:                }
180:
181:                /**
182:                 * Mouse pressed event.
183:                 *
184:                 * @param e  the event.
185:                 */
186:                public void mousePressed(final MouseEvent e) {
187:                    maybeShowPopup(e);
188:                }
189:
190:                /**
191:                 * Mouse released event.
192:                 *
193:                 * @param e  the event.
194:                 */
195:                public void mouseReleased(final MouseEvent e) {
196:                    maybeShowPopup(e);
197:                }
198:
199:                /**
200:                 * Event handler.
201:                 *
202:                 * @param e  the event.
203:                 */
204:                private void maybeShowPopup(final MouseEvent e) {
205:                    if (e.isPopupTrigger()) {
206:                        getCopyPopupMenu().show(getTable(), e.getX(), e.getY());
207:                    }
208:                }
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.