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.beans.PropertyChangeEvent;
22
import java.beans.PropertyChangeListener;
23
import java.util.Date;
26
* Implementation of a bean.
28
public class BeanImpl implements Bean {
30
private PropertyChangeListener listener;
32
private String value = new Date().toString();
40
new Thread(new Runnable() {
46
setValue(new java.util.Date().toString());
48
} catch (InterruptedException ex) {
56
* Add a listener to property changes.
58
* @param listener listener to add
60
public void addPropertyChangeListener(PropertyChangeListener listener) {
63
this.listener = listener;
71
public String getValue() {
78
} catch (InterruptedException ex) {
88
* @param value value to set
90
public void setValue(String value) {
91
String oldValue = this.value;
95
String newValue = this.value;
97
if (listener != null) {
98
listener.propertyChange(new PropertyChangeEvent(this, "value", oldValue, newValue));