public void setRGB(int r, int g, int b) {
        if ((r < 0) || (r > 255)) {
            throw new IllegalArgumentException("The red value (" + r + ") must be between [0,255].");
        }
        if ((g < 0) || (g > 255)) {
            throw new IllegalArgumentException("The green value (" + g + ") must be between [0,255].");
        }
        if ((b < 0) || (b > 255)) {
            throw new IllegalArgumentException("The blue value (" + b + ") must be between [0,255].");
        }

        Color lastColor = getColor();

        boolean updateRGBSpinners = this.adjustingSpinners == 0;

        this.adjustingSpinners++;
        this.adjustingColorPanel++;
        int alpha = this.alpha.getIntValue();
        try {
            if (updateRGBSpinners) {
                this.red.setValue(r);
                this.green.setValue(g);
                this.blue.setValue(b);
            }
            this.preview.setForeground(new Color(r, g, b, alpha));
            float[] hsb = new float[3];
            Color.RGBtoHSB(r, g, b, hsb);
            this.hue.setValue((int) ((hsb[0] * 360f) + .49f));
            this.sat.setValue((int) ((hsb[1] * 100f) + .49f));
            this.bri.setValue((int) ((hsb[2] * 100f) + .49f));
            this.colorPanel.setRGB(r, g, b);
            updateHexField();
            updateSlider();
        } finally {
            this.adjustingSpinners--;
            this.adjustingColorPanel--;
        }
        this.currentRed = r;
        this.currentGreen = g;
        this.currentBlue = b;
        Color newColor = getColor();
        if (lastColor.equals(newColor) == false) {
            firePropertyChange(SELECTED_COLOR_PROPERTY, lastColor, newColor);
        }
    }