~ubuntu-branches/ubuntu/oneiric/libspin-java/oneiric

« back to all changes in this revision

Viewing changes to src/main/java/spin/demo/prompt/CallGUI.java

  • Committer: Bazaar Package Importer
  • Author(s): gregor herrmann
  • Date: 2007-12-16 15:15:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071216151547-0xwxaqstui65ozpd
Tags: 1.5-1
* New upstream release:
  - doesn't use ant anymore but maven; using a workaround with
    maven-ant-helper and our own build.xml
  - doesn't need the patch against build.xml anymore; therefore removing
    ths patch and the dpatch framework
  - depends on libcglib2.1-java; adding the package to Build-Depends-Indep
    and moving libspin-java to contrib because of the dependency
  - the jar now has the version number in the filename; adding a symlink
* Fix debian/watch.
* Clean up debian/rules.
* Move upstream URL from the description to the new Homepage field.
* Change XS-Vcs-* fields to Vcs-*.
* Set Standards-Version to 3.7.3 (no further changes required).
* Add get-orig-source target in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Spin - transparent threading solution for non-freezing Swing applications.
 
3
 * Copyright (C) 2002 Sven Meier
 
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.1 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
package spin.demo.prompt;
 
20
 
 
21
import java.awt.BorderLayout;
 
22
import java.awt.event.ActionEvent;
 
23
import java.awt.event.ActionListener;
 
24
 
 
25
import javax.swing.JButton;
 
26
import javax.swing.JFrame;
 
27
import javax.swing.JOptionPane;
 
28
import javax.swing.JPanel;
 
29
 
 
30
import spin.Spin;
 
31
 
 
32
/**
 
33
 * A demonstration of a GUI showing a call prompt.
 
34
 */
 
35
public class CallGUI extends JPanel {
 
36
 
 
37
        private JButton button = new JButton("Start");
 
38
 
 
39
        private PromptBean promptBean;
 
40
 
 
41
        /**
 
42
         * Constructor.
 
43
         */
 
44
        public CallGUI(PromptBean aPromptBean) {
 
45
                this.promptBean = aPromptBean;
 
46
 
 
47
                setLayout(new BorderLayout());
 
48
 
 
49
                add(button, BorderLayout.CENTER);
 
50
                button.addActionListener(new ActionListener() {
 
51
                        public void actionPerformed(ActionEvent ev) {
 
52
                                button.setEnabled(false);
 
53
 
 
54
                                for (int i = promptBean.size() - 1; i >= 0; i--) {
 
55
                                        String value = promptBean.get(i);
 
56
 
 
57
                                        if (JOptionPane.YES_OPTION == JOptionPane
 
58
                                                        .showConfirmDialog(CallGUI.this, value, "Prompt",
 
59
                                                                        JOptionPane.YES_NO_OPTION)) {
 
60
                                                promptBean.process(i);
 
61
                                        }
 
62
                                }
 
63
 
 
64
                                button.setEnabled(true);
 
65
                        }
 
66
                });
 
67
        }
 
68
 
 
69
        /**
 
70
         * Entrance to this demo.
 
71
         */
 
72
        public static void main(String[] args) {
 
73
 
 
74
                PromptBean promptBean = new PromptBeanImpl();
 
75
                CallGUI callGUI = new CallGUI((PromptBean) Spin.off(promptBean));
 
76
 
 
77
                JFrame frame = new JFrame("Call prompt");
 
78
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
79
                frame.getContentPane().add(callGUI);
 
80
                frame.pack();
 
81
                frame.setVisible(true);
 
82
        }
 
83
}