This is an color picker using scrollbar. I am getting errors namely: setBackground on Label using color constructor. ERRORS: constructor color in this class cannot be applied to given types. (int,int,int) no arguments excepted.
import java.awt.*;`
import java.awt.event.*;
public class Color extends Frame implements AdjustmentListener
{
static Label lb1,lred,lgreen,lblue;
static TextField tf1,tf2,tf3;
static Scrollbar sb,sb1,sb2;
static Panel p_main,p1,p2,p3;
static Color c;
public static void main(String args[])
{
lb1 = new Label("");
lred = new Label("Red");
lgreen = new Label("Green");
lblue = new Label("Blue");
tf1 = new TextField(20);
tf2 = new TextField(20);
tf3 = new TextField(20);
sb = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255);
sb1 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255);
sb2 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255);
c = new Color();
p_main = new Panel();
p1 = new Panel();
p2 = new Panel();
p3 = new Panel();
c.setLayout(new GridLayout(4,3));
p1.setLayout(new GridLayout(1,1));
p1.add(lb1);
p2.setLayout(new GridLayout(1,3));
p2.add(lred);
p2.add(lgreen);
p2.add(lblue);
p3.setLayout(new GridLayout(1,3));
p3.add(tf1);
p3.add(tf2);
p3.add(tf3);
p_main.setLayout(new GridLayout(3,3));
p_main.add(p1);
p_main.add(p2);
p_main.add(p3);
c.add(p_main);
c.add(sb);
c.add(sb1);
c.add(sb2);
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
int red,green,blue;
red = sb.getValue();
green = sb1.getValue();
blue = sb2.getValue();
lb1.setBackground(new Color(red,green,blue));
lred.setBackground(new Color(red,0,0));
lgreen.setBackground(new Color(0,green,0));
lblue.setBackground(new Color(0,0,blue));
Integer ival = new Integer(red);
String str1 = ival.toString();
tf1.setText(str1);
Integer iv = new Integer(green);
String str2 = iv.toString();
tf1.setText(str2);
Integer iva = new Integer(red);
String str3 = iva.toString();
tf1.setText(str3);
}
}