Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

GuiNewControllerFrame.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk
00022  * Contributor(s): ______________________.
00023  */
00024 
00025 package org.objectweb.cjdbc.console.gui.frames;
00026 
00027 import java.awt.Dimension;
00028 import java.awt.FlowLayout;
00029 import java.awt.Toolkit;
00030 import java.awt.event.ActionListener;
00031 
00032 import javax.swing.JButton;
00033 import javax.swing.JFrame;
00034 import javax.swing.JLabel;
00035 import javax.swing.JTextField;
00036 
00037 import org.objectweb.cjdbc.common.i18n.GuiTranslate;
00038 import org.objectweb.cjdbc.console.gui.FrameConfirmKeyListener;
00039 import org.objectweb.cjdbc.console.gui.constants.GuiCommands;
00040 
00041 /**
00042  * This class defines a GuiNewControllerFrame
00043  * 
00044  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00045  * @version 1.0
00046  */
00047 public class GuiNewControllerFrame extends JFrame
00048 {
00049   private JTextField     portNumber;
00050   private JTextField     ipAddressBox;
00051   private ActionListener actionListener;
00052   private FrameConfirmKeyListener keyListener;
00053 
00054   /**
00055    * Creates a new <code>GuiNewControllerFrame.java</code> object
00056    * 
00057    * @param listener that listens to actions
00058    */
00059   public GuiNewControllerFrame(ActionListener listener)
00060   {
00061     super(GuiTranslate.get("frame.controller.title"));
00062     this.actionListener = listener;
00063     Toolkit toolkit = Toolkit.getDefaultToolkit();
00064     Dimension dim = toolkit.getScreenSize();
00065     int screenHeight = dim.height;
00066     int screenWidth = dim.width;
00067     int frameWidth = 450;
00068     int frameHeight = 50;
00069     this.setBounds((screenWidth - frameWidth) / 2,
00070         (screenHeight - frameHeight) / 2, frameWidth, frameHeight);
00071     this.validate();
00072     this.setVisible(false);
00073     this.getContentPane().setLayout(new FlowLayout());
00074 
00075     JButton optionConfirm = new JButton(GuiTranslate.get("frame.ok"));
00076     optionConfirm.setActionCommand(GuiCommands.COMMAND_ADD_CONTROLLER_APPROVE);
00077     optionConfirm.addActionListener(actionListener);
00078     
00079     keyListener = new FrameConfirmKeyListener(optionConfirm);
00080     this.addKeyListener(keyListener);
00081     
00082     this.getContentPane().add(new JLabel(GuiTranslate.get("frame.controller.host")));
00083     ipAddressBox = new JTextField(0);
00084     ipAddressBox.setAlignmentX(CENTER_ALIGNMENT);
00085     ipAddressBox.setText("localhost");
00086     ipAddressBox.addActionListener(actionListener);
00087     ipAddressBox.addKeyListener(keyListener);
00088     this.getContentPane().add(ipAddressBox);
00089 
00090     this.getContentPane().add(new JLabel(GuiTranslate.get("frame.controller.port")));
00091     portNumber = new JTextField(0);
00092     portNumber.setAlignmentX(CENTER_ALIGNMENT);
00093     portNumber.setText("1090");
00094     portNumber.addActionListener(actionListener);
00095     portNumber.addKeyListener(keyListener);
00096     this.getContentPane().add(portNumber);
00097 
00098     
00099     this.getContentPane().add(optionConfirm);
00100 
00101     JButton optionCancel = new JButton(GuiTranslate.get("frame.cancel"));
00102     optionCancel.setActionCommand(GuiCommands.COMMAND_ADD_CONTROLLER_CANCEL);
00103     optionCancel.addActionListener(actionListener);
00104     this.getContentPane().add(optionCancel);
00105 
00106     this.setVisible(false);
00107     this.setDefaultCloseOperation(HIDE_ON_CLOSE);
00108     this.validate();
00109   }
00110   /**
00111    * Returns the ipAddressBox value.
00112    * 
00113    * @return Returns the ipAddressBox.
00114    */
00115   public JTextField getIpAddressBox()
00116   {
00117     return ipAddressBox;
00118   }
00119   /**
00120    * Returns the portNumber value.
00121    * 
00122    * @return Returns the portNumber.
00123    */
00124   public JTextField getPortNumber()
00125   {
00126     return portNumber;
00127   }
00128 }

Generated on Mon Apr 11 22:01:32 2005 for C-JDBC by  doxygen 1.3.9.1