01: /*
02: * Jacareto Copyright (c) 2002-2005
03: * Applied Computer Science Research Group, Darmstadt University of
04: * Technology, Institute of Mathematics & Computer Science,
05: * Ludwigsburg University of Education, and Computer Based
06: * Learning Research Group, Aachen University. All rights reserved.
07: *
08: * Jacareto is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * Jacareto is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public
19: * License along with Jacareto; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: *
22: */
23:
24: package jacareto.comp;
25:
26: import jacareto.system.Environment;
27:
28: import java.awt.Component;
29:
30: import javax.swing.AbstractButton;
31:
32: /**
33: * This is a class which provides methods for abstract buttons. It uses the accessibility API for
34: * the retrieval of the child components of a JComponent in addition to standard methods.
35: *
36: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
37: * @version 1.0
38: */
39: public class AbstractButtonHandler extends JComponentHandler {
40: /**
41: * Creates a new Abstract Button handler.
42: *
43: * @param env the environment
44: * @param components the components instance
45: */
46: public AbstractButtonHandler(Environment env, Components components) {
47: super (env, components);
48: }
49:
50: /**
51: * Returns whether this handler is responsible for the given component. This class is
52: * responsible for AbstractButtons.
53: *
54: * @param component the component
55: *
56: * @return <code>true</code> if this handler is responsible for the given component, otherwise
57: * <code>false</code>
58: */
59: public boolean handlesComponent(Component component) {
60: return (component != null)
61: && component instanceof AbstractButton;
62: }
63:
64: /**
65: * Things that should be done when a component has been added to the components instance.
66: *
67: * @param component the component
68: */
69: public void init(Component component) {
70: ((AbstractButton) component).addActionListener(components
71: .getComponentListener());
72: ((AbstractButton) component).addItemListener(components
73: .getComponentListener());
74: }
75:
76: /** Returns an indicator string, or <code>null</code> if there is no indicator
77: * @param component the component
78: * @return the indicator string
79: */
80: public String getIndicatorString(Component component) {
81: return ((AbstractButton) component).getText();
82: }
83: }
|