FileDocCategorySizeDatePackage
GainControlComponent.javaAPI DocJMF 2.1.1e5893Mon May 12 12:20:50 BST 2003com.sun.media.ui

GainControlComponent

public class GainControlComponent extends Container implements GainChangeListener

Fields Summary
private static JMFSecurity
jmfSecurity
private static boolean
securityPrivelege
private Method[]
m
private Class[]
cl
private Object[]
args
protected GainControl
gain
protected MuteButton
muteButton
protected VolumeButton
upButton
protected VolumeButton
downButton
protected boolean
fUseVolumeControl
protected static final float
VolumeIncrement
protected static final int
RepeatDelay
Constructors Summary
public GainControlComponent(GainControl gain)


     
	try {
	    jmfSecurity = JMFSecurityManager.getJMFSecurity();
	    securityPrivelege = true;
	} catch (SecurityException e) {
	}
    
	GridBagLayout gbl;
	GridBagConstraints gbc = new GridBagConstraints();

	this.gain = gain;
	gain.addGainChangeListener(this);

        setLayout(gbl = new GridBagLayout());

	if (canChangeVolume()) {

	    gbc.insets = new Insets(0, 0, 0, 0);
	    gbc.gridheight = 2;

	    muteButton = new MuteButton();
	    add(muteButton);
	    gbl.setConstraints(muteButton, gbc);

	    gbc.gridx = 1;
	    gbc.gridheight = 1;
	    upButton = new VolumeButton("volumeUp.gif",
				    "volumeUp-active.gif",
				    "volumeUp-pressed.gif",
				    "volumeUp-disabled.gif",
				    "Increase volume",
				    VolumeIncrement);
	    add(upButton);
	    gbl.setConstraints(upButton, gbc);

	    gbc.gridy = 1;
 	    downButton = new VolumeButton("volumeDown.gif",
				      "volumeDown-active.gif",
				      "volumeDown-pressed.gif",
				      "volumeDown-disabled.gif",
				      "Decrease volume",
				      -VolumeIncrement);

	    add(downButton);
	    gbl.setConstraints(downButton, gbc);
        } else {
            fUseVolumeControl=false;
            muteButton = new MuteButton();
	    add(muteButton);
        }

    
Methods Summary
protected booleancanChangeVolume()


        if ( (gain==null) || (gain.getLevel()<0.0f) ) {
          return false;
        }

	return true;
    
public voidgainChange(javax.media.GainChangeEvent e)


        if (fUseVolumeControl==true) {
            float level = e.getLevel();
	    upButton.setEnabled(level < 1.0f);
	    downButton.setEnabled(level > 0.0f);
        }
	muteButton.setValue(e.getMute());