Source Code Cross Referenced for FilePanel.java in  » Testing » jakarta-jmeter » org » apache » jmeter » gui » util » 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 » Testing » jakarta jmeter » org.apache.jmeter.gui.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *   http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         * 
017:         */
018:
019:        package org.apache.jmeter.gui.util;
020:
021:        import java.awt.event.ActionEvent;
022:        import java.awt.event.ActionListener;
023:        import java.util.Iterator;
024:        import java.util.LinkedList;
025:        import java.util.List;
026:
027:        import javax.swing.BorderFactory;
028:        import javax.swing.Box;
029:        import javax.swing.JButton;
030:        import javax.swing.JFileChooser;
031:        import javax.swing.JLabel;
032:        import javax.swing.JTextField;
033:        import javax.swing.event.ChangeEvent;
034:        import javax.swing.event.ChangeListener;
035:
036:        import org.apache.jmeter.util.JMeterUtils;
037:
038:        /**
039:         * author Michael Stover Created April 18, 2002
040:         */
041:        public class FilePanel extends HorizontalPanel implements 
042:                ActionListener {
043:            JTextField filename = new JTextField(20);
044:
045:            JLabel label = new JLabel(JMeterUtils
046:                    .getResString("file_visualizer_filename")); //$NON-NLS-1$
047:
048:            JButton browse = new JButton(JMeterUtils.getResString("browse")); //$NON-NLS-1$
049:
050:            private static final String ACTION_BROWSE = "browse"; //$NON-NLS-1$
051:
052:            List listeners = new LinkedList();
053:
054:            String title;
055:
056:            String filetype;
057:
058:            /**
059:             * Constructor for the FilePanel object.
060:             */
061:            public FilePanel() {
062:                title = ""; //$NON-NLS-1$
063:                init();
064:            }
065:
066:            public FilePanel(String title) {
067:                this .title = title;
068:                init();
069:            }
070:
071:            public FilePanel(String title, String filetype) {
072:                this (title);
073:                this .filetype = filetype;
074:            }
075:
076:            /**
077:             * Constructor for the FilePanel object.
078:             */
079:            public FilePanel(ChangeListener l, String title) {
080:                this .title = title;
081:                init();
082:                listeners.add(l);
083:            }
084:
085:            public void addChangeListener(ChangeListener l) {
086:                listeners.add(l);
087:            }
088:
089:            private void init() {
090:                setBorder(BorderFactory.createTitledBorder(title));
091:                add(label);
092:                add(Box.createHorizontalStrut(5));
093:                add(filename);
094:                add(Box.createHorizontalStrut(5));
095:                filename.addActionListener(this );
096:                add(browse);
097:                browse.setActionCommand(ACTION_BROWSE);
098:                browse.addActionListener(this );
099:
100:            }
101:
102:            public void clearGui() {
103:                filename.setText(""); // $NON-NLS-1$
104:            }
105:
106:            /**
107:             * If the gui needs to enable/disable the FilePanel, call the method.
108:             * 
109:             * @param enable
110:             */
111:            public void enableFile(boolean enable) {
112:                browse.setEnabled(enable);
113:                filename.setEnabled(enable);
114:            }
115:
116:            /**
117:             * Gets the filename attribute of the FilePanel object.
118:             * 
119:             * @return the filename value
120:             */
121:            public String getFilename() {
122:                return filename.getText();
123:            }
124:
125:            /**
126:             * Sets the filename attribute of the FilePanel object.
127:             * 
128:             * @param f
129:             *            the new filename value
130:             */
131:            public void setFilename(String f) {
132:                filename.setText(f);
133:            }
134:
135:            private void fireFileChanged() {
136:                Iterator iter = listeners.iterator();
137:                while (iter.hasNext()) {
138:                    ((ChangeListener) iter.next())
139:                            .stateChanged(new ChangeEvent(this ));
140:                }
141:            }
142:
143:            public void actionPerformed(ActionEvent e) {
144:                if (e.getActionCommand().equals(ACTION_BROWSE)) {
145:                    JFileChooser chooser;
146:                    if (filetype == null) {
147:                        chooser = FileDialoger.promptToOpenFile();
148:                    } else {
149:                        chooser = FileDialoger
150:                                .promptToOpenFile(new String[] { filetype });
151:                    }
152:                    if (chooser != null && chooser.getSelectedFile() != null) {
153:                        filename.setText(chooser.getSelectedFile().getPath());
154:                        fireFileChanged();
155:                    }
156:                } else {
157:                    fireFileChanged();
158:                }
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.