1 19 package org.netbeans.modules.ruby.railsprojects.server; 20 21 import javax.swing.event.ChangeListener ; 22 23 28 public class PortConflictPanel extends javax.swing.JPanel { 29 private ChangeListener changeListener; 30 31 32 public PortConflictPanel(int port) { 33 initComponents(); 34 portField.setText(Integer.toString(port)); 35 } 36 37 public int getPort() { 38 String portText = portField.getText(); 39 int port = Integer.parseInt(portText); 40 if (port <= 1024) { 41 port = 1025; 43 } 44 if (port > 65535) { 45 port = 65535; 47 } 48 return port; 49 } 50 51 56 private void initComponents() { 58 59 jLabel1 = new javax.swing.JLabel (); 60 jLabel2 = new javax.swing.JLabel (); 61 jLabel3 = new javax.swing.JLabel (); 62 jSeparator1 = new javax.swing.JSeparator (); 63 jLabel4 = new javax.swing.JLabel (); 64 jLabel5 = new javax.swing.JLabel (); 65 portField = new javax.swing.JTextField (); 66 67 jLabel1.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.jLabel1.text")); 69 jLabel2.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.jLabel2.text")); 71 jLabel3.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.jLabel3.text")); 73 jLabel4.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.jLabel4.text")); 75 jLabel5.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.jLabel5.text")); 77 portField.setColumns(8); 78 portField.setText(org.openide.util.NbBundle.getMessage(PortConflictPanel.class, "PortConflictPanel.portField.text")); 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 } 119 120 private javax.swing.JLabel jLabel1; 122 private javax.swing.JLabel jLabel2; 123 private javax.swing.JLabel jLabel3; 124 private javax.swing.JLabel jLabel4; 125 private javax.swing.JLabel jLabel5; 126 private javax.swing.JSeparator jSeparator1; 127 private javax.swing.JTextField portField; 128 130 } 131 | Popular Tags |