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
21
import java.awt.BorderLayout;
22
import java.beans.PropertyChangeEvent;
23
import java.beans.PropertyChangeListener;
25
import javax.swing.JFrame;
26
import javax.swing.JLabel;
27
import javax.swing.JPanel;
32
* A demonstration of a GUI using spin over.
34
public class SpinOverGUI extends JPanel implements PropertyChangeListener {
36
private JLabel label = new JLabel("???");
41
public SpinOverGUI() {
42
setLayout(new BorderLayout());
44
add(label, BorderLayout.CENTER);
45
label.setHorizontalAlignment(JLabel.CENTER);
46
label.setVerticalAlignment (JLabel.CENTER);
50
* @see java.beans.PropertyChangeListener
52
public void propertyChange(PropertyChangeEvent evt) {
56
if ("value".equals(evt.getPropertyName())) {
57
String text = (String)evt.getNewValue();
64
* Entrance to this demo.
66
public static void main(String[] args) {
68
Bean bean = new BeanImpl();
69
SpinOverGUI spinOverGUI = new SpinOverGUI();
70
bean.addPropertyChangeListener((PropertyChangeListener)Spin.over(spinOverGUI));
72
JFrame frame = new JFrame("Spin over");
73
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
74
frame.getContentPane().add(spinOverGUI);
76
frame.setVisible(true);