Source Code Cross Referenced for AddVMDialog.java in  » Byte-Code » PROSE » ch » ethz » prose » tools » 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 » Byte Code » PROSE » ch.ethz.prose.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        //  This file is part of the prose package.
003:        //
004:        //  The contents of this file are subject to the Mozilla Public License
005:        //  Version 1.1 (the "License"); you may not use this file except in
006:        //  compliance with the License. You may obtain a copy of the License at
007:        //  http://www.mozilla.org/MPL/
008:        //
009:        //  Software distributed under the License is distributed on an "AS IS" basis,
010:        //  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011:        //  for the specific language governing rights and limitations under the
012:        //  License.
013:        //
014:        //  The Original Code is prose.
015:        //
016:        //  The Initial Developer of the Original Code is Andrei Popovici. Portions
017:        //  created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
018:        //  All Rights Reserved.
019:        //
020:        //  Contributor(s):
021:        /*
022:         * AddVMDialog.java
023:         *
024:         * Created on December 30, 2002, 4:18 PM
025:         */
026:
027:        package ch.ethz.prose.tools;
028:
029:        import javax.swing.event.DocumentEvent;
030:        import javax.swing.event.DocumentListener;
031:        import javax.swing.text.BadLocationException;
032:        import javax.swing.text.Document;
033:
034:        /**
035:         *
036:         * @author  pschoch
037:         */
038:        public class AddVMDialog extends javax.swing.JDialog {
039:
040:            private static final long serialVersionUID = 3256728398360556336L;
041:            private String nameVM = null;
042:            private String ip = "";
043:            private String port = "5000";
044:
045:            /** Creates new form AddVMDialog */
046:            public AddVMDialog(java.awt.Frame parent, boolean modal) {
047:                super (parent, modal);
048:                initComponents();
049:                customizeComponents();
050:            }
051:
052:            protected class MyDocumentListener implements  DocumentListener {
053:                private String which;
054:
055:                public MyDocumentListener(String which) {
056:                    this .which = which;
057:                }
058:
059:                public void insertUpdate(DocumentEvent e) {
060:                    displayEditInfo(e);
061:                }
062:
063:                public void removeUpdate(DocumentEvent e) {
064:                    displayEditInfo(e);
065:                }
066:
067:                public void changedUpdate(DocumentEvent e) {
068:                    // Plain Text components don't fire this events.
069:                }
070:
071:                private void displayEditInfo(DocumentEvent e) {
072:                    String text = null;
073:                    Document doc = (Document) e.getDocument();
074:                    try {
075:                        text = doc.getText(0, doc.getLength());
076:                    } catch (BadLocationException es) {
077:                        throw new Error("bad location in AddVMDialog");
078:                    }
079:                    if (which.equals("name"))
080:                        nameVM = text;
081:                    else if (which.equals("ip"))
082:                        ip = text;
083:                    else if (which.equals("port"))
084:                        port = text;
085:                    else
086:                        throw new RuntimeException("wrong label: " + which);
087:                }
088:            }
089:
090:            /** This method is called from within the constructor to
091:             * initialize the form.
092:             * WARNING: Do NOT modify this code. The content of this method is
093:             * always regenerated by the Form Editor.
094:             */
095:            private void initComponents() {//GEN-BEGIN:initComponents
096:                input = new javax.swing.JPanel();
097:                namePane = new javax.swing.JPanel();
098:                nameLabel = new javax.swing.JLabel();
099:                nameTextField = new javax.swing.JTextField();
100:                ipPane = new javax.swing.JPanel();
101:                ipLabel = new javax.swing.JLabel();
102:                ipTextField = new javax.swing.JTextField();
103:                portPane = new javax.swing.JPanel();
104:                portLabel = new javax.swing.JLabel();
105:                portTextField = new javax.swing.JTextField();
106:                buttons = new javax.swing.JPanel();
107:                addButton = new javax.swing.JButton();
108:                cancelButton = new javax.swing.JButton();
109:
110:                setTitle("Add new Virtual Machine");
111:                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
112:                setName("addVMDialog");
113:                addWindowListener(new java.awt.event.WindowAdapter() {
114:                    public void windowClosing(java.awt.event.WindowEvent evt) {
115:                        closeDialog(evt);
116:                    }
117:                });
118:
119:                input.setLayout(new javax.swing.BoxLayout(input,
120:                        javax.swing.BoxLayout.Y_AXIS));
121:
122:                input.setPreferredSize(new java.awt.Dimension(300, 200));
123:                input.setMinimumSize(new java.awt.Dimension(300, 200));
124:                namePane.setLayout(new javax.swing.BoxLayout(namePane,
125:                        javax.swing.BoxLayout.X_AXIS));
126:
127:                namePane.setBorder(new javax.swing.border.EmptyBorder(
128:                        new java.awt.Insets(5, 10, 5, 10)));
129:                namePane.setAlignmentX(0.0F);
130:                namePane.setMaximumSize(new java.awt.Dimension(300, 58));
131:                nameLabel.setText("Name:");
132:                nameLabel
133:                        .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
134:                nameLabel.setPreferredSize(new java.awt.Dimension(80, 29));
135:                nameLabel.setBorder(new javax.swing.border.EmptyBorder(
136:                        new java.awt.Insets(1, 1, 1, 10)));
137:                nameLabel.setMinimumSize(new java.awt.Dimension(100, 29));
138:                nameLabel.setMaximumSize(new java.awt.Dimension(100, 29));
139:                namePane.add(nameLabel);
140:
141:                nameTextField.setToolTipText("name of the VM");
142:                nameTextField.setAlignmentX(1.0F);
143:                nameTextField.setPreferredSize(new java.awt.Dimension(200, 29));
144:                nameTextField.setMaximumSize(new java.awt.Dimension(200, 29));
145:                nameTextField.setMinimumSize(new java.awt.Dimension(200, 29));
146:                namePane.add(nameTextField);
147:
148:                input.add(namePane);
149:
150:                ipPane.setLayout(new javax.swing.BoxLayout(ipPane,
151:                        javax.swing.BoxLayout.X_AXIS));
152:
153:                ipPane.setBorder(new javax.swing.border.EmptyBorder(
154:                        new java.awt.Insets(5, 10, 5, 10)));
155:                ipPane.setAlignmentX(0.0F);
156:                ipPane.setMaximumSize(new java.awt.Dimension(300, 58));
157:                ipLabel.setText("IP:");
158:                ipLabel
159:                        .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
160:                ipLabel.setPreferredSize(new java.awt.Dimension(80, 29));
161:                ipLabel.setBorder(new javax.swing.border.EmptyBorder(
162:                        new java.awt.Insets(1, 1, 1, 10)));
163:                ipLabel.setMinimumSize(new java.awt.Dimension(100, 29));
164:                ipLabel.setMaximumSize(new java.awt.Dimension(100, 29));
165:                ipPane.add(ipLabel);
166:
167:                ipTextField
168:                        .setToolTipText("IP-Address OR www-Address OR Hostname");
169:                ipTextField.setAlignmentX(1.0F);
170:                ipTextField.setPreferredSize(new java.awt.Dimension(200, 29));
171:                ipTextField.setMaximumSize(new java.awt.Dimension(200, 29));
172:                ipTextField.setMinimumSize(new java.awt.Dimension(200, 29));
173:                ipPane.add(ipTextField);
174:
175:                input.add(ipPane);
176:
177:                portPane.setLayout(new javax.swing.BoxLayout(portPane,
178:                        javax.swing.BoxLayout.X_AXIS));
179:
180:                portPane.setBorder(new javax.swing.border.EmptyBorder(
181:                        new java.awt.Insets(5, 10, 5, 10)));
182:                portPane.setPreferredSize(new java.awt.Dimension(222, 29));
183:                portPane.setMinimumSize(new java.awt.Dimension(222, 29));
184:                portPane.setAlignmentX(0.0F);
185:                portPane.setMaximumSize(new java.awt.Dimension(300, 58));
186:                portLabel.setText("Port:");
187:                portLabel
188:                        .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
189:                portLabel.setPreferredSize(new java.awt.Dimension(60, 29));
190:                portLabel.setBorder(new javax.swing.border.EmptyBorder(
191:                        new java.awt.Insets(1, 1, 1, 10)));
192:                portLabel.setMinimumSize(new java.awt.Dimension(100, 29));
193:                portLabel.setMaximumSize(new java.awt.Dimension(100, 29));
194:                portPane.add(portLabel);
195:
196:                portTextField.setToolTipText("Portnumber");
197:                portTextField.setText("5000");
198:                portTextField.setPreferredSize(new java.awt.Dimension(200, 29));
199:                portTextField.setMaximumSize(new java.awt.Dimension(200, 29));
200:                portTextField.setMinimumSize(new java.awt.Dimension(200, 29));
201:                portPane.add(portTextField);
202:
203:                input.add(portPane);
204:
205:                getContentPane().add(input, java.awt.BorderLayout.CENTER);
206:
207:                buttons.setLayout(new java.awt.FlowLayout(
208:                        java.awt.FlowLayout.CENTER, 20, 15));
209:
210:                addButton.setMnemonic('A');
211:                addButton.setText("Add");
212:                addButton.setPreferredSize(new java.awt.Dimension(81, 29));
213:                addButton.setMaximumSize(new java.awt.Dimension(81, 29));
214:                addButton.setMinimumSize(new java.awt.Dimension(81, 29));
215:                addButton
216:                        .addActionListener(new java.awt.event.ActionListener() {
217:                            public void actionPerformed(
218:                                    java.awt.event.ActionEvent evt) {
219:                                addButtonActionPerformed(evt);
220:                            }
221:                        });
222:
223:                addButton.addKeyListener(new java.awt.event.KeyAdapter() {
224:                    public void keyPressed(java.awt.event.KeyEvent evt) {
225:                        addButtonKeyPressed(evt);
226:                    }
227:                });
228:
229:                buttons.add(addButton);
230:
231:                cancelButton.setMnemonic('C');
232:                cancelButton.setText("Cancel");
233:                cancelButton
234:                        .addActionListener(new java.awt.event.ActionListener() {
235:                            public void actionPerformed(
236:                                    java.awt.event.ActionEvent evt) {
237:                                cancelButtonActionPerformed(evt);
238:                            }
239:                        });
240:
241:                buttons.add(cancelButton);
242:                getContentPane().add(buttons, java.awt.BorderLayout.SOUTH);
243:                pack();
244:            }//GEN-END:initComponents
245:
246:            private void addButtonKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_addButtonKeyPressed
247:                if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER)
248:                    addButtonAction();
249:            }//GEN-LAST:event_addButtonKeyPressed
250:
251:            private void cancelButtonActionPerformed(
252:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
253:                setVisible(false);
254:                dispose();
255:            }//GEN-LAST:event_cancelButtonActionPerformed
256:
257:            private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
258:                addButtonAction();
259:            }//GEN-LAST:event_addButtonActionPerformed
260:
261:            /** Closes the dialog */
262:            private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
263:                setVisible(false);
264:                dispose();
265:            }//GEN-LAST:event_closeDialog
266:
267:            private void addButtonAction() {
268:                try {
269:                    ((JMultipleProseClient) getOwner()).addTab(nameVM, ip,
270:                            port, true);
271:                    setVisible(false);
272:                    dispose();
273:                } catch (Exception e) {
274:                    JMultipleProseClient.showException(this , e);
275:                    if (e instanceof  java.rmi.RemoteException) {
276:                        setVisible(false);
277:                        dispose();
278:                    }
279:                }
280:            }
281:
282:            private void customizeComponents() {
283:                nameTextField.getDocument().addDocumentListener(
284:                        new MyDocumentListener("name"));
285:                portTextField.getDocument().addDocumentListener(
286:                        new MyDocumentListener("port"));
287:                ipTextField.getDocument().addDocumentListener(
288:                        new MyDocumentListener("ip"));
289:                this .setLocationRelativeTo(this .getParent());
290:            }
291:
292:            // Variables declaration - do not modify//GEN-BEGIN:variables
293:            private javax.swing.JLabel nameLabel;
294:            private javax.swing.JPanel portPane;
295:            private javax.swing.JLabel ipLabel;
296:            private javax.swing.JPanel input;
297:            private javax.swing.JTextField ipTextField;
298:            private javax.swing.JButton addButton;
299:            private javax.swing.JPanel buttons;
300:            private javax.swing.JButton cancelButton;
301:            private javax.swing.JTextField portTextField;
302:            private javax.swing.JPanel ipPane;
303:            private javax.swing.JLabel protocolLabel;
304:            private javax.swing.JLabel portLabel;
305:            private javax.swing.JPanel namePane;
306:            private javax.swing.JTextField nameTextField;
307:            private javax.swing.JPanel protocolPane;
308:            private javax.swing.JTextField protocolTextField;
309:            // End of variables declaration//GEN-END:variables
310:
311:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.