KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > console > lib > gui > GUIInitDialog


1 /*
2 * CLIF is a Load Injection Framework
3 * Copyright (C) 2003 France Telecom R&D
4 * Copyright (C) 2003 INRIA
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * CLIF $Name: $
21 *
22 * Contact: clif@objectweb.org
23 */

24
25 package org.objectweb.clif.console.lib.gui;
26
27 import javax.swing.*;
28 import java.awt.event.ActionListener JavaDoc;
29 import java.awt.event.ActionEvent JavaDoc;
30 import java.awt.event.WindowAdapter JavaDoc;
31 import java.awt.event.WindowEvent JavaDoc;
32 import java.awt.*;
33
34
35 /**
36  *
37  * @author Bruno Dillenseger
38  */

39 public class GUIInitDialog extends JDialog implements ActionListener JavaDoc
40 {
41     static protected int last_id = 0;
42     protected JButton okBtn;
43     protected JTextField idFld;
44     protected String JavaDoc value = null;
45
46
47     GUIInitDialog(JFrame frame)
48     {
49         super(frame, "Please enter test unique identifier", true);
50         Container pane = getContentPane();
51         pane.setLayout(new BorderLayout());
52         pane.add(BorderLayout.NORTH, new JLabel("new test id:"));
53         pane.add(BorderLayout.CENTER, idFld = new JTextField("test#" + last_id, 20));
54         pane.add(BorderLayout.SOUTH, okBtn = new JButton("OK"));
55         okBtn.addActionListener(this);
56         this.addWindowListener(new WindowCloser());
57     }
58
59
60     public String JavaDoc ask()
61     {
62         pack();
63         show();
64         return value;
65     }
66
67
68     public void actionPerformed(ActionEvent JavaDoc e)
69     {
70         if (e.getSource() == okBtn)
71         {
72             ++last_id;
73             value = idFld.getText();
74         }
75         this.dispose();
76     }
77
78     class WindowCloser extends WindowAdapter JavaDoc
79     {
80         public void windowClosing(WindowEvent JavaDoc e)
81         {
82             GUIInitDialog.this.dispose();
83         }
84     }
85 }
86
Popular Tags