KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > analyser > 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
26 package org.objectweb.clif.analyser.lib.gui;
27
28 import javax.swing.*;
29 import java.awt.event.ActionListener JavaDoc;
30 import java.awt.event.ActionEvent JavaDoc;
31 import java.awt.event.WindowAdapter JavaDoc;
32 import java.awt.event.WindowEvent JavaDoc;
33 import java.awt.*;
34
35
36 /**
37  * @author Damien Croizer
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     GuiInitDialog(JFrame frame,String JavaDoc dialogType)
61     {
62     super(frame, "Chose an option", true);
63     
64     if(dialogType.equals("option"))
65         {
66         Container pane = getContentPane();
67         pane.setLayout(new BorderLayout());
68         String JavaDoc[] option = new String JavaDoc[4];
69         option[0] = "1 - hit per second";
70         option[1] = "2 - hit per ten seconds";
71         option[2] = "3 - hit per minute";
72         option[3] = "4 - response time";
73         pane.add(BorderLayout.NORTH, new JList(option));
74         pane.add(BorderLayout.CENTER, idFld = new JTextField("4", 20));
75         pane.add(BorderLayout.SOUTH, okBtn = new JButton("OK"));
76         okBtn.addActionListener(this);
77         this.addWindowListener(new WindowCloser());
78         }
79     }
80     
81     GuiInitDialog(JFrame frame,int inutile)
82     {
83     super(frame, "Enter the rule's name that you want to start/stop", true);
84     Container pane = getContentPane();
85     pane.setLayout(new BorderLayout());
86     pane.add(BorderLayout.NORTH, new JLabel(""));
87     pane.add(BorderLayout.CENTER, idFld = new JTextField("", 20));
88     pane.add(BorderLayout.SOUTH, okBtn = new JButton("OK"));
89     okBtn.addActionListener(this);
90     this.addWindowListener(new WindowCloser());
91     }
92     
93     
94     public String JavaDoc ask()
95     {
96     pack();
97     show();
98     return value;
99     }
100     
101
102     public void actionPerformed(ActionEvent JavaDoc e)
103     {
104         if (e.getSource() == okBtn)
105         {
106             ++last_id;
107             value = idFld.getText();
108         }
109         this.dispose();
110     }
111
112     class WindowCloser extends WindowAdapter JavaDoc
113     {
114         public void windowClosing(WindowEvent JavaDoc e)
115         {
116             GuiInitDialog.this.dispose();
117         }
118     }
119 }
120
Popular Tags