1 7 8 package javax.sound.sampled; 9 10 28 public abstract class BooleanControl extends Control { 29 30 31 33 36 private final String trueStateLabel; 37 38 41 private final String falseStateLabel; 42 43 46 private boolean value; 47 48 49 51 52 62 protected BooleanControl(Type type, boolean initialValue, String trueStateLabel, String falseStateLabel) { 63 64 super(type); 65 this.value = initialValue; 66 this.trueStateLabel = trueStateLabel; 67 this.falseStateLabel = falseStateLabel; 68 } 69 70 71 79 protected BooleanControl(Type type, boolean initialValue) { 80 this(type, initialValue, "true", "false"); 81 } 82 83 84 86 87 94 public void setValue(boolean value) { 95 this.value = value; 96 } 97 98 99 100 104 public boolean getValue() { 105 return value; 106 } 107 108 109 114 public String getStateLabel(boolean state) { 115 return ((state == true) ? trueStateLabel : falseStateLabel); 116 } 117 118 119 120 122 123 127 public String toString() { 128 return new String (super.toString() + " with current value: " + getStateLabel(getValue())); 129 } 130 131 132 134 135 144 public static class Type extends Control.Type { 145 146 147 149 150 154 public static final Type MUTE = new Type("Mute"); 155 156 162 public static final Type APPLY_REVERB = new Type("Apply Reverb"); 163 164 165 167 168 172 protected Type(String name) { 173 super(name); 174 } 175 } } 177 | Popular Tags |