KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > gui > frames > jmxdesktop > SetSubjectDialog


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.jmxdesktop;
26
27 import java.awt.BorderLayout JavaDoc;
28 import java.awt.GridLayout JavaDoc;
29 import java.awt.event.ActionEvent JavaDoc;
30 import java.awt.event.ActionListener JavaDoc;
31
32 import javax.swing.JButton JavaDoc;
33 import javax.swing.JDialog 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.CjdbcGui;
39 import org.objectweb.cjdbc.console.gui.constants.GuiCommands;
40 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
41
42 /**
43  * This class defines a SetSubjectDialog
44  *
45  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
46  * @version 1.0
47  */

48 public class SetSubjectDialog extends JDialog JavaDoc implements ActionListener JavaDoc
49 {
50
51   private JTextField JavaDoc user;
52   private JTextField JavaDoc password;
53   private CjdbcGui gui;
54
55   /**
56    * Creates a new <code>SetSubjectDialog</code> object
57    *
58    * @param gui the GUI
59    * @throws java.awt.HeadlessException
60    */

61   public SetSubjectDialog(CjdbcGui gui)
62   {
63     super(gui, "Set Subject", true);
64     GuiConstants.centerComponent(this, 300, 100);
65
66     this.getContentPane().setLayout(new BorderLayout JavaDoc());
67     this.getContentPane().setLayout(new GridLayout JavaDoc(3, 2));
68
69     user = new JTextField JavaDoc("");
70     JLabel JavaDoc userLabel = new JLabel JavaDoc("User");
71     this.getContentPane().add(userLabel);
72     this.getContentPane().add(user);
73
74     password = new JTextField JavaDoc("");
75     JLabel JavaDoc passwordLabel = new JLabel JavaDoc("Password");
76     this.getContentPane().add(passwordLabel);
77     this.getContentPane().add(password);
78
79     JButton JavaDoc ok = new JButton JavaDoc(GuiTranslate
80         .get("frame.ok"));
81     ok.setActionCommand(GuiCommands.COMMAND_CONFIRM_ACTION);
82     ok.addActionListener(this);
83     this.getContentPane().add(ok);
84
85     JButton JavaDoc cancel = new JButton JavaDoc(GuiTranslate
86         .get("frame.cancel"));
87     cancel.setActionCommand(GuiCommands.COMMAND_CANCEL_ACTION);
88     cancel.addActionListener(this);
89     this.getContentPane().add(cancel);
90
91     this.validate();
92     this.gui = gui;
93     this.setVisible(true);
94
95   }
96
97   /**
98    * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
99    */

100   public void actionPerformed(ActionEvent JavaDoc e)
101   {
102     if (e.getActionCommand().equalsIgnoreCase(
103         GuiCommands.COMMAND_CONFIRM_ACTION))
104     {
105       gui.getCurrentJmxClient().setCurrentSubject(user.getText(),
106           password.getText());
107       this.setVisible(false);
108     }
109     else if (e.getActionCommand().equalsIgnoreCase(
110         GuiCommands.COMMAND_CANCEL_ACTION))
111     {
112       this.setVisible(false);
113     }
114   }
115 }
116
Popular Tags