001: /*
002: * Copyright (c) 2001 Silvere Martin-Michiellot All Rights Reserved.
003: *
004: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
005: * royalty free, license to use, modify and redistribute this
006: * software in source and binary code form,
007: * provided that i) this copyright notice and license appear on all copies of
008: * the software; and ii) Licensee does not utilize the software in a manner
009: * which is disparaging to Silvere Martin-Michiellot.
010: *
011: * This software is provided "AS IS," without a warranty of any kind. ALL
012: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
013: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
014: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
015: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
016: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
017: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
018: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
019: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
020: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
021: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
022: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
023: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
024: *
025: * This software is not designed or intended for use in on-line control of
026: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
027: * the design, construction, operation or maintenance of any nuclear
028: * facility. Licensee represents and warrants that it will not use or
029: * redistribute the Software for such purposes.
030: *
031: * @Author: Silvere Martin-Michiellot
032: *
033: */
034:
035: package com.db.server;
036:
037: import java.awt.*;
038: import java.awt.event.*;
039: import java.net.*;
040: import java.util.*;
041: import javax.swing.*;
042:
043: public class GateJDialog extends JDialog implements ActionListener {
044:
045: private DigitalBiosphereServer parent;
046:
047: private JPanel jPanel3;
048: private JLabel jLabel2;
049: private JPanel jPanel4;
050: private JLabel jLabel3;
051: private JTextField jTextField1;
052: private JLabel jLabel4;
053: private JTextField jTextField2;
054: private JLabel jLabel5;
055: private JTextField jTextField3;
056: private JPanel jPanel6;
057: private JButton jButton3;
058: private JButton jButton4;
059:
060: public GateJDialog(DigitalBiosphereServer parent,
061: ResourceBundle resourceBundle) {
062:
063: super (parent);
064:
065: this .parent = parent;
066: jPanel3 = new JPanel();
067: jLabel2 = new JLabel();
068: jPanel4 = new JPanel();
069: jLabel3 = new JLabel();
070: jTextField1 = new JTextField();
071: jLabel4 = new JLabel();
072: jTextField2 = new JTextField();
073: jLabel5 = new JLabel();
074: jTextField3 = new JTextField();
075: jPanel6 = new JPanel();
076: jButton3 = new JButton();
077: jButton4 = new JButton();
078:
079: this .getContentPane().setLayout(new FlowLayout());
080: this .setName(resourceBundle
081: .getString("Create New Server Reference"));
082: this .setModal(true);
083: this .setTitle(resourceBundle
084: .getString("Create New Server Reference"));
085: this .setResizable(false);
086:
087: /* The following code is to close the windows. */
088:
089: this .addWindowListener(new WindowAdapter() {
090:
091: public void windowClosing(WindowEvent e) {
092:
093: setVisible(false);
094: dispose();
095:
096: }
097:
098: });
099:
100: this .addWindowListener(new WindowAdapter() {
101:
102: public void windowIconified(WindowEvent e) {
103:
104: setVisible(false);
105: dispose();
106:
107: }
108:
109: });
110:
111: jPanel3.setPreferredSize(new Dimension(250, 30));
112: jPanel3.setMinimumSize(new Dimension(250, 30));
113: jPanel3.setMaximumSize(new Dimension(250, 30));
114:
115: jLabel2.setText(resourceBundle
116: .getString("Please select a Name, IP and Port:"));
117: jPanel3.add(jLabel2);
118:
119: this .getContentPane().add(jPanel3);
120:
121: jPanel4.setLayout(new GridLayout(5, 2));
122: jPanel4.setPreferredSize(new Dimension(300, 120));
123: jPanel4.setMinimumSize(new Dimension(300, 120));
124: jPanel4.setMaximumSize(new Dimension(300, 120));
125:
126: jLabel4.setText(resourceBundle.getString("Server Name:"));
127: jPanel4.add(jLabel4);
128:
129: jTextField2.setColumns(40);
130: jTextField2.setToolTipText(resourceBundle
131: .getString("ServerNameToolTipText"));
132: jTextField2.getAccessibleContext().setAccessibleDescription(
133: resourceBundle
134: .getString("ServerNameAccessibleDescription"));
135: jPanel4.add(jTextField2);
136:
137: jLabel3.setText(resourceBundle.getString("Server IP:"));
138: jPanel4.add(jLabel3);
139:
140: jTextField1.setColumns(40);
141: jTextField1.setToolTipText(resourceBundle
142: .getString("ServerIPToolTipText"));
143: jTextField1.getAccessibleContext().setAccessibleDescription(
144: resourceBundle
145: .getString("ServerIPAccessibleDescription"));
146: jPanel4.add(jTextField1);
147:
148: jLabel5.setText(resourceBundle.getString("Server Port:"));
149: jPanel4.add(jLabel5);
150:
151: jTextField3.setColumns(40);
152: jTextField3.setToolTipText(resourceBundle
153: .getString("ServerPortToolTipText"));
154: jTextField3.getAccessibleContext().setAccessibleDescription(
155: resourceBundle
156: .getString("ServerPortAccessibleDescription"));
157: jPanel4.add(jTextField3);
158:
159: this .getContentPane().add(jPanel4);
160:
161: jPanel6.setPreferredSize(new Dimension(250, 40));
162: jPanel6.setMinimumSize(new Dimension(250, 40));
163: jPanel6.setMaximumSize(new Dimension(250, 40));
164:
165: jButton3.setText("OK");
166: jButton3.addActionListener(this );
167: jButton3.setToolTipText(resourceBundle
168: .getString("OKToolTipText"));
169: jButton3.getAccessibleContext().setAccessibleDescription(
170: resourceBundle.getString("OKAccessibleDescription"));
171: jPanel6.add(jButton3);
172:
173: jButton4.setText("Cancel");
174: jButton4.addActionListener(this );
175: jButton4.setToolTipText(resourceBundle
176: .getString("CancelToolTipText"));
177: jButton4
178: .getAccessibleContext()
179: .setAccessibleDescription(
180: resourceBundle
181: .getString("CancelAccessibleDescription"));
182: jPanel6.add(jButton4);
183:
184: this .getContentPane().add(jPanel6);
185:
186: this .pack();
187:
188: }
189:
190: public void actionPerformed(ActionEvent TheActionEvent) {
191:
192: InetAddress inetAddress;
193: Object TheObject;
194:
195: TheObject = TheActionEvent.getSource();
196:
197: if (TheObject instanceof JButton) {
198: if (TheObject == jButton3) {
199: try {
200: inetAddress = InetAddress.getByName(jTextField2
201: .getText());
202: this .TheSetCommand(jTextField1.getText(),
203: inetAddress, new Integer(jTextField3
204: .getText()).intValue());
205: this .TheCloseCommand();
206: } catch (UnknownHostException unknownHostException) {
207: jTextField2.setText(new String(""));
208: }
209: }
210: if (TheObject == jButton4) {
211: this .TheCloseCommand();
212: }
213: }
214:
215: }
216:
217: private void TheSetCommand(String name, InetAddress inetAddress,
218: int port) {
219:
220: this .parent.setGateJDialogResult(name, inetAddress, port);
221:
222: }
223:
224: private void TheCloseCommand() {
225:
226: this .setVisible(false);
227: this.dispose();
228:
229: }
230:
231: }
|