public void setMode(int mode) {
        if (!((mode == HUE) || (mode == SAT) || (mode == BRI) || (mode == RED) || (mode == GREEN) || (mode == BLUE))) {
            throw new IllegalArgumentException("mode must be HUE, SAT, BRI, REd, GREEN, or BLUE");
        }
        putClientProperty(MODE_PROPERTY, new Integer(mode));
        this.hue.radioButton.setSelected(mode == HUE);
        this.sat.radioButton.setSelected(mode == SAT);
        this.bri.radioButton.setSelected(mode == BRI);
        this.red.radioButton.setSelected(mode == RED);
        this.green.radioButton.setSelected(mode == GREEN);
        this.blue.radioButton.setSelected(mode == BLUE);

        this.colorPanel.setMode(mode);
        this.adjustingSlider++;
        try {
            this.slider.setValue(0);
            Option option = getSelectedOption();
            this.slider.setInverted(mode == HUE);
            int max = option.getMaximum();
            this.slider.setMaximum(max);
            this.slider.setValue(option.getIntValue());
            this.slider.repaint();

            if ((mode == HUE) || (mode == SAT) || (mode == BRI)) {
                setHSB(this.hue.getFloatValue() / 360f,
                        this.sat.getFloatValue() / 100f,
                        this.bri.getFloatValue() / 100f);
            } else {
                setRGB(this.red.getIntValue(),
                        this.green.getIntValue(),
                        this.blue.getIntValue());

            }
        } finally {
            this.adjustingSlider--;
        }
    }