KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > gui > frames > GuiNewControllerFrame


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.console.gui.frames;
26
27 import java.awt.Dimension JavaDoc;
28 import java.awt.FlowLayout JavaDoc;
29 import java.awt.Toolkit JavaDoc;
30 import java.awt.event.ActionListener JavaDoc;
31
32 import javax.swing.JButton JavaDoc;
33 import javax.swing.JFrame JavaDoc;
34 import javax.swing.JLabel JavaDoc;
35 import javax.swing.JTextField JavaDoc;
36
37 import org.objectweb.cjdbc.common.i18n.GuiTranslate;
38 import org.objectweb.cjdbc.console.gui.FrameConfirmKeyListener;
39 import org.objectweb.cjdbc.console.gui.constants.GuiCommands;
40
41 /**
42  * This class defines a GuiNewControllerFrame
43  *
44  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
45  * @version 1.0
46  */

47 public class GuiNewControllerFrame extends JFrame JavaDoc
48 {
49   private JTextField JavaDoc portNumber;
50   private JTextField JavaDoc ipAddressBox;
51   private ActionListener JavaDoc actionListener;
52   private FrameConfirmKeyListener keyListener;
53
54   /**
55    * Creates a new <code>GuiNewControllerFrame.java</code> object
56    *
57    * @param listener that listens to actions
58    */

59   public GuiNewControllerFrame(ActionListener JavaDoc listener)
60   {
61     super(GuiTranslate.get("frame.controller.title"));
62     this.actionListener = listener;
63     Toolkit JavaDoc toolkit = Toolkit.getDefaultToolkit();
64     Dimension JavaDoc dim = toolkit.getScreenSize();
65     int screenHeight = dim.height;
66     int screenWidth = dim.width;
67     int frameWidth = 450;
68     int frameHeight = 50;
69     this.setBounds((screenWidth - frameWidth) / 2,
70         (screenHeight - frameHeight) / 2, frameWidth, frameHeight);
71     this.validate();
72     this.setVisible(false);
73     this.getContentPane().setLayout(new FlowLayout JavaDoc());
74
75     JButton JavaDoc optionConfirm = new JButton JavaDoc(GuiTranslate.get("frame.ok"));
76     optionConfirm.setActionCommand(GuiCommands.COMMAND_ADD_CONTROLLER_APPROVE);
77     optionConfirm.addActionListener(actionListener);
78     
79     keyListener = new FrameConfirmKeyListener(optionConfirm);
80     this.addKeyListener(keyListener);
81     
82     this.getContentPane().add(new JLabel JavaDoc(GuiTranslate.get("frame.controller.host")));
83     ipAddressBox = new JTextField JavaDoc(0);
84     ipAddressBox.setAlignmentX(CENTER_ALIGNMENT);
85     ipAddressBox.setText("localhost");
86     ipAddressBox.addActionListener(actionListener);
87     ipAddressBox.addKeyListener(keyListener);
88     this.getContentPane().add(ipAddressBox);
89
90     this.getContentPane().add(new JLabel JavaDoc(GuiTranslate.get("frame.controller.port")));
91     portNumber = new JTextField JavaDoc(0);
92     portNumber.setAlignmentX(CENTER_ALIGNMENT);
93     portNumber.setText("1090");
94     portNumber.addActionListener(actionListener);
95     portNumber.addKeyListener(keyListener);
96     this.getContentPane().add(portNumber);
97
98     
99     this.getContentPane().add(optionConfirm);
100
101     JButton JavaDoc optionCancel = new JButton JavaDoc(GuiTranslate.get("frame.cancel"));
102     optionCancel.setActionCommand(GuiCommands.COMMAND_ADD_CONTROLLER_CANCEL);
103     optionCancel.addActionListener(actionListener);
104     this.getContentPane().add(optionCancel);
105
106     this.setVisible(false);
107     this.setDefaultCloseOperation(HIDE_ON_CLOSE);
108     this.validate();
109   }
110   /**
111    * Returns the ipAddressBox value.
112    *
113    * @return Returns the ipAddressBox.
114    */

115   public JTextField JavaDoc getIpAddressBox()
116   {
117     return ipAddressBox;
118   }
119   /**
120    * Returns the portNumber value.
121    *
122    * @return Returns the portNumber.
123    */

124   public JTextField JavaDoc getPortNumber()
125   {
126     return portNumber;
127   }
128 }
129
Popular Tags