public void setMode(int mode) {
        if (!((mode == ColorPicker.HUE) || (mode == ColorPicker.SAT) || (mode == ColorPicker.BRI) ||
                (mode == ColorPicker.RED) || (mode == ColorPicker.GREEN) || (mode == ColorPicker.BLUE))) {
            throw new IllegalArgumentException("The mode must be HUE, SAT, BRI, RED, GREEN, or BLUE.");
        }

        if (this.mode == mode) {
            return;
        }
        this.mode = mode;
        regenerateImage();
        regeneratePoint();
    }