FileDocCategorySizeDatePackage
BooleanControl.javaAPI DocJava SE 5 API4891Fri Aug 26 14:57:50 BST 2005javax.sound.sampled

BooleanControl

public abstract class BooleanControl extends Control
A BooleanControl provides the ability to switch between two possible settings that affect a line's audio. The settings are boolean values (true and false). A graphical user interface might represent the control by a two-state button, an on/off switch, two mutually exclusive buttons, or a checkbox (among other possibilities). For example, depressing a button might activate a {@link BooleanControl.Type#MUTE MUTE} control to silence the line's audio.

As with other {@link Control} subclasses, a method is provided that returns string labels for the values, suitable for display in the user interface.

author
Kara Kytle
version
1.15, 03/12/19
since
1.3

Fields Summary
private final String
trueStateLabel
The true state label, such as "true" or "on."
private final String
falseStateLabel
The false state label, such as "false" or "off."
private boolean
value
The current value.
Constructors Summary
protected BooleanControl(Type type, boolean initialValue, String trueStateLabel, String falseStateLabel)
Constructs a new boolean control object with the given parameters.

param
type the type of control represented this float control object
param
initialValue the initial control value
param
trueStateLabel the label for the state represented by true, such as "true" or "on."
param
falseStateLabel the label for the state represented by false, such as "false" or "off."

	
	super(type);
	this.value = initialValue;
	this.trueStateLabel = trueStateLabel;
	this.falseStateLabel = falseStateLabel;
    
protected BooleanControl(Type type, boolean initialValue)
Constructs a new boolean control object with the given parameters. The labels for the true and false states default to "true" and "false."

param
type the type of control represented by this float control object
param
initialValue the initial control value

	this(type, initialValue, "true", "false");
    
Methods Summary
public java.lang.StringgetStateLabel(boolean state)
Obtains the label for the specified state.

return
the label for the specified state, such as "true" or "on" for true, or "false" or "off" for false.

	return ((state == true) ? trueStateLabel : falseStateLabel);
    
public booleangetValue()
Obtains this control's current value.

return
current value.

	return value;
    
public voidsetValue(boolean value)
Sets the current value for the control. The default implementation simply sets the value as indicated. Some controls require that their line be open before they can be affected by setting a value.

param
value desired new value.

	this.value = value;
    
public java.lang.StringtoString()
Provides a string representation of the control

return
a string description

	return new String(super.toString() + " with current value: " + getStateLabel(getValue()));