2
* Spin - transparent threading solution for non-freezing Swing applications.
3
* Copyright (C) 2002 Sven Meier
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.1 of the License, or (at your option) any later version.
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.
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
19
package spin.demo.prompt;
21
import java.awt.BorderLayout;
22
import java.awt.event.ActionEvent;
23
import java.awt.event.ActionListener;
25
import javax.swing.JButton;
26
import javax.swing.JFrame;
27
import javax.swing.JOptionPane;
28
import javax.swing.JPanel;
33
* A demonstration of a GUI showing a call prompt.
35
public class CallGUI extends JPanel {
37
private JButton button = new JButton("Start");
39
private PromptBean promptBean;
44
public CallGUI(PromptBean aPromptBean) {
45
this.promptBean = aPromptBean;
47
setLayout(new BorderLayout());
49
add(button, BorderLayout.CENTER);
50
button.addActionListener(new ActionListener() {
51
public void actionPerformed(ActionEvent ev) {
52
button.setEnabled(false);
54
for (int i = promptBean.size() - 1; i >= 0; i--) {
55
String value = promptBean.get(i);
57
if (JOptionPane.YES_OPTION == JOptionPane
58
.showConfirmDialog(CallGUI.this, value, "Prompt",
59
JOptionPane.YES_NO_OPTION)) {
60
promptBean.process(i);
64
button.setEnabled(true);
70
* Entrance to this demo.
72
public static void main(String[] args) {
74
PromptBean promptBean = new PromptBeanImpl();
75
CallGUI callGUI = new CallGUI((PromptBean) Spin.off(promptBean));
77
JFrame frame = new JFrame("Call prompt");
78
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
79
frame.getContentPane().add(callGUI);
81
frame.setVisible(true);