import java.awt.event.*;
import java.awt.*;
import java.applet.Applet;
public class ColorSettingApplet extends Applet{
int R=0,G=0,B=0;
TextField redValue =new TextField("0",3);
TextField greenValue=new TextField("0",3);
TextField blueValue =new TextField("0",3);
Button butt =new Button("update");
public void init(){
add(redValue);
add(greenValue);
add(blueValue);
add(butt);
butt.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
repaint();
}
});
}
public void paint(Graphics g){
try {
R=Integer.parseInt(redValue.getText());
G=Integer.parseInt(greenValue.getText());
B=Integer.parseInt(blueValue.getText());
} catch (NumberFormatException e){
System.out.println("Error color value");
}
g.setColor(new Color(R,G,B));
g.fillRect(50,50,100,50);
}
}