KickJava   Java API By Example, From Geeks To Geeks.

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


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

23
24 package org.objectweb.clif.console.lib.gui;
25
26 import javax.swing.JDialog JavaDoc;
27 import javax.swing.JButton JavaDoc;
28 import javax.swing.JFrame JavaDoc;
29 import javax.swing.JLabel JavaDoc;
30 import javax.swing.JPanel JavaDoc;
31 import java.awt.event.ActionListener JavaDoc;
32 import java.awt.event.ActionEvent JavaDoc;
33 import java.awt.event.WindowAdapter JavaDoc;
34 import java.awt.event.WindowEvent JavaDoc;
35 import java.awt.Container JavaDoc;
36 import java.awt.BorderLayout JavaDoc;
37
38
39 /**
40  *
41  * @author Bruno Dillenseger
42  */

43 public class GuiClearConfirm extends JDialog JavaDoc implements ActionListener JavaDoc
44 {
45     protected JButton JavaDoc okBtn, cancelBtn;
46     protected boolean value = false;
47
48
49     GuiClearConfirm(JFrame JavaDoc frame)
50     {
51         super(frame, "Test plan reset", true);
52         Container JavaDoc pane = getContentPane();
53         pane.setLayout(new BorderLayout JavaDoc());
54         pane.add(BorderLayout.CENTER, new JLabel JavaDoc("Current test plan will be discarded"));
55         JPanel JavaDoc buttonPnl = new JPanel JavaDoc();
56         buttonPnl.add(okBtn = new JButton JavaDoc("OK"));
57         okBtn.addActionListener(this);
58         buttonPnl.add(cancelBtn = new JButton JavaDoc("cancel"));
59         cancelBtn.addActionListener(this);
60         pane.add(BorderLayout.SOUTH, buttonPnl);
61         addWindowListener(new WindowCloser());
62     }
63
64
65     public boolean ask()
66     {
67         pack();
68         show();
69         return value;
70     }
71
72
73     public void actionPerformed(ActionEvent JavaDoc e)
74     {
75         if (e.getSource() == okBtn)
76         {
77             value = true;
78         }
79         this.dispose();
80     }
81
82
83     class WindowCloser extends WindowAdapter JavaDoc
84     {
85         public void windowClosing(WindowEvent JavaDoc e)
86         {
87             GuiClearConfirm.this.dispose();
88         }
89     }
90 }
91
Popular Tags