01: package org.uispec4j;
02:
03: import junit.framework.Assert;
04: import org.uispec4j.assertion.Assertion;
05:
06: import javax.swing.*;
07: import java.awt.*;
08:
09: /**
10: * Wrapper for JCheckBox components.
11: */
12: public class CheckBox extends AbstractButton {
13: public static final String TYPE_NAME = "checkBox";
14: public static final Class[] SWING_CLASSES = { JCheckBox.class };
15:
16: private JCheckBox jCheckBox;
17:
18: public CheckBox(JCheckBox checkBox) {
19: super (checkBox);
20: this .jCheckBox = checkBox;
21: }
22:
23: public Component getAwtComponent() {
24: return jCheckBox;
25: }
26:
27: public String getDescriptionTypeName() {
28: return TYPE_NAME;
29: }
30:
31: public void select() {
32: if (!jCheckBox.isSelected()) {
33: click();
34: }
35: }
36:
37: public void unselect() {
38: if (jCheckBox.isSelected()) {
39: click();
40: }
41: }
42:
43: public Assertion isSelected() {
44: return new Assertion() {
45: public void check() {
46: Assert.assertTrue(jCheckBox.isSelected());
47: }
48: };
49: }
50: }
|