Java program to create frame with three scrolls & change the background color using RGB function.

Below code is used to create frame with three scrolls & change the background color using RGB function:

import java.awt.*; 
import java.awt.event.*; 

public class ScrollDemo extends Frame implements AdjustmentListener 
{
    Scrollbar redScroll, greenScroll, blueScroll; 
    Label redLabel, greenLabel, blueLabel; 
    Panel p1;
    public ScrollDemo() 
    {
        addWindowListener(new MyWindowAdapter());
        setBackground(Color.lightGray); 
        p1 = new Panel(); 
        p1.setLayout(new GridLayout(3, 2, 5, 5)); 
        redScroll = new Scrollbar(Scrollbar.HORIZONTAL, 0, 0, 0, 255); 
        p1.add(redLabel = new Label("RED")); 
        redLabel.setBackground(Color.white);
        p1.add(redScroll);      
        greenScroll = new Scrollbar(Scrollbar.HORIZONTAL, 0, 0, 0, 255); 
        p1.add(greenLabel = new Label("GREEN"));
        greenLabel.setBackground(Color.white);
        p1.add(greenScroll);
        blueScroll = new Scrollbar(Scrollbar.HORIZONTAL, 0, 0, 0, 255); 
        p1.add(blueLabel = new Label("BLUE"));
        blueLabel.setBackground(Color.white);
        p1.add(blueScroll);  
        redScroll.addAdjustmentListener(this);
        greenScroll.addAdjustmentListener(this);        
        blueScroll.addAdjustmentListener(this);
        add(p1,"South");
        setTitle("Playing With Colors"); 
        setSize(450,325); 
        setVisible(true); 
    }
    public void adjustmentValueChanged(AdjustmentEvent e) 
    { 
        int rv = redScroll.getValue();
        int gv = greenScroll.getValue(); 
        int bv = blueScroll.getValue();
        redLabel.setText("RED: "+ rv); 
        greenLabel.setText("GREEN: "+ gv); 
        blueLabel.setText("BLUE: "+ bv); 
        Color clr1 = new Color(rv, gv, bv); 
        setBackground(clr1); 
    }
    public static void main(String args[]) 
    {
        new ScrollDemo(); 
    }
}
class MyWindowAdapter extends WindowAdapter 
{
    public void windowClosing(WindowEvent we)
    {
        System.exit(0);
    }
}

Thank You.