Source Code Cross Referenced for PNLAwtEvents.java in  » Swing-Library » swingexplorer » org » swingexplorer » awt_events » 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 » Swing Library » swingexplorer » org.swingexplorer.awt_events 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Swing Explorer. Tool for developers exploring Java/Swing-based application internals. 
003:         * Copyright (C) 2008, Maxim Zakharenkov
004:         *
005:         * This program is free software; you can redistribute it and/or modify
006:         * it under the terms of the GNU General Public License as published by
007:         * the Free Software Foundation; either version 2 of the License, or
008:         * (at your option) any later version.
009:         *
010:         * This program is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:         * GNU General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU General Public License along
016:         * with this program; if not, write to the Free Software Foundation, Inc.,
017:         * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
018:         * 
019:         * $Header: /cvs/swingexplorer/src/org/swingexplorer/awt_events/PNLAwtEvents.java,v 1.4 2008/03/07 11:46:51 maxz1 Exp $
020:         */
021:        package org.swingexplorer.awt_events;
022:
023:        import java.awt.AWTEvent;
024:        import java.awt.event.AWTEventListener;
025:        import java.awt.event.MouseAdapter;
026:        import java.awt.event.MouseEvent;
027:        import java.beans.PropertyChangeEvent;
028:        import java.beans.PropertyChangeListener;
029:
030:        import javax.swing.ActionMap;
031:        import javax.swing.InputMap;
032:        import javax.swing.KeyStroke;
033:        import javax.swing.ListSelectionModel;
034:
035:        import org.swingexplorer.RichAction;
036:        import org.swingexplorer.plaf.CustomSplitPaneUI;
037:
038:        /**
039:         *
040:         * @author Maxim Zakharenkov
041:         */
042:        public class PNLAwtEvents extends javax.swing.JPanel {
043:
044:            /** Creates new form PNLEvents */
045:            public PNLAwtEvents() {
046:                initComponents();
047:                sppMasterDetail.setResizeWeight(1);
048:                setEventModel(new LocalAWTEventModel(this ));
049:                tblEvents.setModel(mdlTblEvents);
050:                initActions();
051:                tblEvents.getColumnModel().getColumn(0).setPreferredWidth(120);
052:                tblEvents.getColumnModel().getColumn(1).setPreferredWidth(40);
053:                tblEvents.getColumnModel().getColumn(2).setPreferredWidth(120);
054:                tblEvents.getSelectionModel().setSelectionMode(
055:                        ListSelectionModel.SINGLE_SELECTION);
056:
057:                eventModel
058:                        .addPropertyChangeListener(new ModelPropertyChangeListener());
059:            }
060:
061:            void initActions() {
062:                actStartEventMonitoring = new ActStartEventMonitoring(
063:                        eventModel);
064:                actStopEventMonitoring = new ActStopEventMonitoring(eventModel);
065:
066:                InputMap map = tblEvents
067:                        .getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
068:                map.put(KeyStroke.getKeyStroke("ENTER"), "show-source");
069:
070:                tblEvents.addMouseListener(new MouseAdapter() {
071:                    @Override
072:                    public void mouseClicked(MouseEvent e) {
073:                        if (e.getClickCount() == 2) {
074:                            actShowEventSource.actionPerformed(null);
075:                        }
076:                    }
077:                });
078:
079:                actClearEvents = new ActClearEvents(mdlTblEvents);
080:                btnClear.setAction(actClearEvents);
081:                btnStart.setAction(actStartEventMonitoring);
082:                tblEvents.getSelectionModel().addListSelectionListener(
083:                        new ActEventSelected(this ));
084:
085:                actShowFilter = new ActShowFilter(this );
086:                btnShowFilter.setAction(actShowFilter);
087:            }
088:
089:            public void setShowEventSourceAction(RichAction act) {
090:                btnShowSource.setAction(act);
091:                ActionMap actMap = tblEvents.getActionMap();
092:                actMap.put("show-source", act);
093:                actShowEventSource = act;
094:            }
095:
096:            public AWTEvent getSelectedEvent() {
097:                int selRow = tblEvents.getSelectedRow();
098:                return mdlTblEvents.getEvent(selRow);
099:            }
100:
101:            public void addEvent(AWTEvent evt) {
102:                mdlTblEvents.addEvent(evt);
103:
104:                int rowNo = mdlTblEvents.getRowCount() - 1;
105:                mdlTblEvents.fireTableRowsInserted(rowNo, rowNo);
106:                txtStatus.setText("Events: " + mdlTblEvents.getRowCount());
107:
108:                tblEvents.scrollRectToVisible(tblEvents.getCellRect(rowNo, 1,
109:                        true));
110:            }
111:
112:            public void setEventModel(AWTEventModel modelP) {
113:                if (eventModel != null) {
114:                    eventModel.removeEventListener(modelListener);
115:                }
116:
117:                eventModel = modelP;
118:                eventModel.addEventListener(modelListener);
119:            }
120:
121:            public AWTEventModel getEventModel() {
122:                return eventModel;
123:            }
124:
125:            class ModelListener implements  AWTEventListener {
126:                public void eventDispatched(AWTEvent event) {
127:                    addEvent(event);
128:                }
129:            }
130:
131:            public class ModelPropertyChangeListener implements 
132:                    PropertyChangeListener {
133:                public void propertyChange(PropertyChangeEvent evt) {
134:                    if ("monitoring".equals(evt.getPropertyName())) {
135:                        if ((Boolean) evt.getNewValue()) {
136:                            btnStart.setAction(actStopEventMonitoring);
137:                        } else {
138:                            btnStart.setAction(actStartEventMonitoring);
139:                        }
140:                    }
141:                }
142:            }
143:
144:            /** This method is called from within the constructor to
145:             * initialize the form.
146:             * WARNING: Do NOT modify this code. The content of this method is
147:             * always regenerated by the Form Editor.
148:             */
149:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
150:            private void initComponents() {
151:
152:                sppMasterDetail = new javax.swing.JSplitPane();
153:                pnlEventDetails = new org.swingexplorer.awt_events.PNLEventDetails();
154:                scpTable = new javax.swing.JScrollPane();
155:                tblEvents = new javax.swing.JTable();
156:                txtStatus = new javax.swing.JTextField();
157:                btnStart = new javax.swing.JButton();
158:                btnClear = new javax.swing.JButton();
159:                btnShowSource = new javax.swing.JButton();
160:                btnShowFilter = new javax.swing.JButton();
161:
162:                sppMasterDetail.setDividerLocation(300);
163:                sppMasterDetail.setMinimumSize(new java.awt.Dimension(0, 0));
164:                sppMasterDetail.setRightComponent(pnlEventDetails);
165:
166:                scpTable.setMinimumSize(new java.awt.Dimension(0, 0));
167:
168:                tblEvents.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
169:                scpTable.setViewportView(tblEvents);
170:
171:                sppMasterDetail.setLeftComponent(scpTable);
172:
173:                txtStatus.setBackground(javax.swing.UIManager.getDefaults()
174:                        .getColor("Panel.background"));
175:                txtStatus.setEditable(false);
176:                txtStatus.setBorder(null);
177:                txtStatus.setMinimumSize(new java.awt.Dimension(0, 0));
178:
179:                btnStart.setText("Start");
180:                btnStart.setToolTipText("Start event monitoring");
181:                btnStart
182:                        .setBorder(javax.swing.BorderFactory
183:                                .createBevelBorder(javax.swing.border.BevelBorder.RAISED));
184:                btnStart.setPreferredSize(new java.awt.Dimension(31, 19));
185:
186:                btnClear.setText("Clear");
187:                btnClear.setToolTipText("Clear all current events");
188:                btnClear
189:                        .setBorder(javax.swing.BorderFactory
190:                                .createBevelBorder(javax.swing.border.BevelBorder.RAISED));
191:
192:                btnShowSource.setText("Source");
193:                btnShowSource
194:                        .setToolTipText("Show selected event's component in the tree");
195:                btnShowSource
196:                        .setBorder(javax.swing.BorderFactory
197:                                .createBevelBorder(javax.swing.border.BevelBorder.RAISED));
198:
199:                btnShowFilter.setText("Filter");
200:                btnShowFilter
201:                        .setBorder(javax.swing.BorderFactory
202:                                .createBevelBorder(javax.swing.border.BevelBorder.RAISED));
203:
204:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
205:                        this );
206:                this .setLayout(layout);
207:                layout
208:                        .setHorizontalGroup(layout
209:                                .createParallelGroup(
210:                                        org.jdesktop.layout.GroupLayout.LEADING)
211:                                .add(
212:                                        layout
213:                                                .createSequentialGroup()
214:                                                .add(
215:                                                        btnStart,
216:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
217:                                                        36,
218:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
219:                                                .add(0, 0, 0)
220:                                                .add(
221:                                                        btnClear,
222:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
223:                                                        36,
224:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
225:                                                .add(0, 0, 0)
226:                                                .add(btnShowSource)
227:                                                .add(0, 0, 0)
228:                                                .add(btnShowFilter)
229:                                                .addPreferredGap(
230:                                                        org.jdesktop.layout.LayoutStyle.UNRELATED)
231:                                                .add(
232:                                                        txtStatus,
233:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
234:                                                        348, Short.MAX_VALUE))
235:                                .add(
236:                                        org.jdesktop.layout.GroupLayout.TRAILING,
237:                                        sppMasterDetail,
238:                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
239:                                        496, Short.MAX_VALUE));
240:                layout
241:                        .setVerticalGroup(layout
242:                                .createParallelGroup(
243:                                        org.jdesktop.layout.GroupLayout.LEADING)
244:                                .add(
245:                                        layout
246:                                                .createSequentialGroup()
247:                                                .add(
248:                                                        layout
249:                                                                .createParallelGroup(
250:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
251:                                                                .add(
252:                                                                        btnStart,
253:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
254:                                                                        22,
255:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
256:                                                                .add(
257:                                                                        txtStatus,
258:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
259:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
260:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
261:                                                                .add(
262:                                                                        btnClear,
263:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
264:                                                                        22,
265:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
266:                                                                .add(
267:                                                                        btnShowSource,
268:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
269:                                                                        22,
270:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
271:                                                                .add(
272:                                                                        btnShowFilter,
273:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
274:                                                                        21,
275:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
276:                                                .addPreferredGap(
277:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
278:                                                .add(
279:                                                        sppMasterDetail,
280:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
281:                                                        117, Short.MAX_VALUE)));
282:
283:                layout.linkSize(new java.awt.Component[] { btnClear,
284:                        btnShowFilter, btnShowSource, btnStart },
285:                        org.jdesktop.layout.GroupLayout.VERTICAL);
286:
287:            }// </editor-fold>//GEN-END:initComponents
288:
289:            // Variables declaration - do not modify//GEN-BEGIN:variables
290:            private javax.swing.JButton btnClear;
291:            javax.swing.JButton btnShowFilter;
292:            private javax.swing.JButton btnShowSource;
293:            private javax.swing.JButton btnStart;
294:            org.swingexplorer.awt_events.PNLEventDetails pnlEventDetails;
295:            private javax.swing.JScrollPane scpTable;
296:            private javax.swing.JSplitPane sppMasterDetail;
297:            private javax.swing.JTable tblEvents;
298:            private javax.swing.JTextField txtStatus;
299:            // End of variables declaration//GEN-END:variables
300:
301:            MdlEvents mdlTblEvents = new MdlEvents();
302:            AWTEventModel eventModel;
303:            AWTEventListener modelListener = new ModelListener();
304:            ActStartEventMonitoring actStartEventMonitoring;
305:            ActStopEventMonitoring actStopEventMonitoring;
306:            ActClearEvents actClearEvents;
307:            RichAction actShowEventSource;
308:            ActShowFilter actShowFilter;
309:        }
310:
311:        /*
312:         * $Log: PNLAwtEvents.java,v $
313:         * Revision 1.4  2008/03/07 11:46:51  maxz1
314:         * Added thread violation monitor and EDT hang monitor. Changed L & F.
315:         *
316:         * Revision 1.3  2008/02/13 21:52:11  maxz1
317:         * Added event filtering functionality
318:         *
319:         * Revision 1.2  2008/02/06 08:36:08  maxz1
320:         * Changed license header
321:         *
322:         * Revision 1.1  2007/06/27 19:41:37  maxz1
323:         * new
324:         *
325:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.