KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ruby > railsprojects > server > PortConflictPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.ruby.railsprojects.server;
20
21 import javax.swing.event.ChangeListener JavaDoc;
22
23 /**
24  * Panel for configuring a new port number to be used
25  *
26  * @author Tor Norbye
27  */

28 public class PortConflictPanel extends javax.swing.JPanel JavaDoc {
29     private ChangeListener JavaDoc changeListener;
30     
31     /** Creates new form PortConflictPanel */
32     public PortConflictPanel(int port) {
33         initComponents();
34         portField.setText(Integer.toString(port));
35     }
36     
37     public int getPort() {
38         String JavaDoc portText = portField.getText();
39         int port = Integer.parseInt(portText);
40         if (port <= 1024) {
41             // TODO - error message
42
port = 1025;
43         }
44         if (port > 65535) {
45             // TODO - error message
46
port = 65535;
47         }
48         return port;
49     }
50     
51     /** This method is called from within the constructor to
52      * initialize the form.
53      * WARNING: Do NOT modify this code. The content of this method is
54      * always regenerated by the Form Editor.
55      */

56     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
57
private void initComponents() {
58
59         jLabel1 = new javax.swing.JLabel JavaDoc();
60         jLabel2 = new javax.swing.JLabel JavaDoc();
61         jLabel3 = new javax.swing.JLabel JavaDoc();
62         jSeparator1 = new javax.swing.JSeparator JavaDoc();
63         jLabel4 = new javax.swing.JLabel JavaDoc();
64         jLabel5 = new javax.swing.JLabel JavaDoc();
65         portField = new javax.swing.JTextField JavaDoc();
66
67         jLabel1.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.jLabel1.text")); // NOI18N
68

69         jLabel2.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.jLabel2.text")); // NOI18N
70

71         jLabel3.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.jLabel3.text")); // NOI18N
72

73         jLabel4.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.jLabel4.text")); // NOI18N
74

75         jLabel5.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.jLabel5.text")); // NOI18N
76

77         portField.setColumns(8);
78         portField.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.portField.text")); // NOI18N
79

80         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
81         this.setLayout(layout);
82         layout.setHorizontalGroup(
83             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
84             .add(layout.createSequentialGroup()
85                 .addContainerGap()
86                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
87                     .add(jLabel1)
88                     .add(jLabel2)
89                     .add(jLabel3)
90                     .add(jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE)
91                     .add(jLabel4)
92                     .add(layout.createSequentialGroup()
93                         .add(jLabel5)
94                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
95                         .add(portField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
96                 .addContainerGap())
97         );
98         layout.setVerticalGroup(
99             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
100             .add(layout.createSequentialGroup()
101                 .addContainerGap()
102                 .add(jLabel1)
103                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
104                 .add(jLabel2)
105                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
106                 .add(jLabel3)
107                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
108                 .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
109                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
110                 .add(jLabel4)
111                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
112                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
113                     .add(jLabel5)
114                     .add(portField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
115                 .addContainerGap(136, Short.MAX_VALUE))
116         );
117     }// </editor-fold>//GEN-END:initComponents
118

119     
120     // Variables declaration - do not modify//GEN-BEGIN:variables
121
private javax.swing.JLabel JavaDoc jLabel1;
122     private javax.swing.JLabel JavaDoc jLabel2;
123     private javax.swing.JLabel JavaDoc jLabel3;
124     private javax.swing.JLabel JavaDoc jLabel4;
125     private javax.swing.JLabel JavaDoc jLabel5;
126     private javax.swing.JSeparator JavaDoc jSeparator1;
127     private javax.swing.JTextField JavaDoc portField;
128     // End of variables declaration//GEN-END:variables
129

130 }
131
Popular Tags