GateJDialog.java :  » 6.0-JDK-Modules » java-3d » com » db » server » Java Open Source

Java Open Source » 6.0 JDK Modules » java 3d 
java 3d » com » db » server » GateJDialog.java
/*
 * Copyright (c) 2001 Silvere Martin-Michiellot All Rights Reserved.
 *
 * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
 * royalty free, license to use, modify and redistribute this
 * software in source and binary code form,
 * provided that i) this copyright notice and license appear on all copies of
 * the software; and ii) Licensee does not utilize the software in a manner
 * which is disparaging to Silvere Martin-Michiellot.
 *
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
 * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
 * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
 * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 *
 * This software is not designed or intended for use in on-line control of
 * aircraft, air traffic, aircraft navigation or aircraft communications; or in
 * the design, construction, operation or maintenance of any nuclear
 * facility. Licensee represents and warrants that it will not use or
 * redistribute the Software for such purposes.
 *
 * @Author: Silvere Martin-Michiellot
 *
 */

package com.db.server;

import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.util.*;
import javax.swing.*;


public class GateJDialog extends JDialog implements ActionListener {
    
    private DigitalBiosphereServer parent;
    
    private JPanel jPanel3;
    private JLabel jLabel2;
    private JPanel jPanel4;
    private JLabel jLabel3;
    private JTextField jTextField1;
    private JLabel jLabel4;
    private JTextField jTextField2;
    private JLabel jLabel5;
    private JTextField jTextField3;
    private JPanel jPanel6;
    private JButton jButton3;
    private JButton jButton4;
    
    public GateJDialog(DigitalBiosphereServer parent, ResourceBundle resourceBundle) {
        
        super (parent);
        
        this.parent = parent;
        jPanel3 = new JPanel();
        jLabel2 = new JLabel();
        jPanel4 = new JPanel();
        jLabel3 = new JLabel();
        jTextField1 = new JTextField();
        jLabel4 = new JLabel();
        jTextField2 = new JTextField();
        jLabel5 = new JLabel();
        jTextField3 = new JTextField();
        jPanel6 = new JPanel();
        jButton3 = new JButton();
        jButton4 = new JButton();
        
        this.getContentPane().setLayout(new FlowLayout());
        this.setName(resourceBundle.getString("Create New Server Reference"));
        this.setModal(true);
        this.setTitle(resourceBundle.getString("Create New Server Reference"));
        this.setResizable(false);
        
    /* The following code is to close the windows. */
        
        this.addWindowListener(new WindowAdapter() {
            
            public void windowClosing(WindowEvent e) {
                
                setVisible(false);
                dispose();
                
            }
            
        });
        
        this.addWindowListener(new WindowAdapter() {
            
            public void windowIconified(WindowEvent e) {
                
                setVisible(false);
                dispose();
                
            }
            
        });
        
        jPanel3.setPreferredSize(new Dimension(250, 30));
        jPanel3.setMinimumSize(new Dimension(250, 30));
        jPanel3.setMaximumSize(new Dimension(250, 30));
        
        jLabel2.setText(resourceBundle.getString("Please select a Name, IP and Port:"));
        jPanel3.add(jLabel2);
        
        this.getContentPane().add(jPanel3);
        
        jPanel4.setLayout(new GridLayout(5, 2));
        jPanel4.setPreferredSize(new Dimension(300, 120));
        jPanel4.setMinimumSize(new Dimension(300, 120));
        jPanel4.setMaximumSize(new Dimension(300, 120));
        
        jLabel4.setText(resourceBundle.getString("Server Name:"));
        jPanel4.add(jLabel4);
        
        jTextField2.setColumns(40);
        jTextField2.setToolTipText(resourceBundle.getString("ServerNameToolTipText"));
        jTextField2.getAccessibleContext().setAccessibleDescription(resourceBundle.getString("ServerNameAccessibleDescription"));
        jPanel4.add(jTextField2);
        
        jLabel3.setText(resourceBundle.getString("Server IP:"));
        jPanel4.add(jLabel3);
        
        jTextField1.setColumns(40);
        jTextField1.setToolTipText(resourceBundle.getString("ServerIPToolTipText"));
        jTextField1.getAccessibleContext().setAccessibleDescription(resourceBundle.getString("ServerIPAccessibleDescription"));
        jPanel4.add(jTextField1);
        
        jLabel5.setText(resourceBundle.getString("Server Port:"));
        jPanel4.add(jLabel5);
        
        jTextField3.setColumns(40);
        jTextField3.setToolTipText(resourceBundle.getString("ServerPortToolTipText"));
        jTextField3.getAccessibleContext().setAccessibleDescription(resourceBundle.getString("ServerPortAccessibleDescription"));
        jPanel4.add(jTextField3);
        
        this.getContentPane().add(jPanel4);
        
        jPanel6.setPreferredSize(new Dimension(250, 40));
        jPanel6.setMinimumSize(new Dimension(250, 40));
        jPanel6.setMaximumSize(new Dimension(250, 40));
        
        jButton3.setText("OK");
        jButton3.addActionListener(this);
        jButton3.setToolTipText(resourceBundle.getString("OKToolTipText"));
        jButton3.getAccessibleContext().setAccessibleDescription(resourceBundle.getString("OKAccessibleDescription"));
        jPanel6.add(jButton3);
        
        jButton4.setText("Cancel");
        jButton4.addActionListener(this);
        jButton4.setToolTipText(resourceBundle.getString("CancelToolTipText"));
        jButton4.getAccessibleContext().setAccessibleDescription(resourceBundle.getString("CancelAccessibleDescription"));
        jPanel6.add(jButton4);
        
        this.getContentPane().add(jPanel6);
        
        this.pack();
        
    }
    
    
    public void actionPerformed(ActionEvent TheActionEvent) {
        
        InetAddress inetAddress;
        Object TheObject;
        
        TheObject = TheActionEvent.getSource();
        
        if (TheObject instanceof JButton) {
            if (TheObject == jButton3) {
                try {
                    inetAddress = InetAddress.getByName(jTextField2.getText());
                    this.TheSetCommand(jTextField1.getText(), inetAddress, new Integer(jTextField3.getText()).intValue());
                    this.TheCloseCommand();
                } catch (UnknownHostException unknownHostException) {
                    jTextField2.setText(new String(""));
                }
            }
            if (TheObject == jButton4) {
                this.TheCloseCommand();
            }
        }
        
    }
    
    private void TheSetCommand(String name, InetAddress inetAddress, int port) {
        
        this.parent.setGateJDialogResult(name, inetAddress, port);
        
    }
    
    private void TheCloseCommand() {
        
        this.setVisible(false);
        this.dispose();
        
    }
    
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.