Colors
Corresponding source code:
import java.awt.*;
public class ColorTest extends java.applet.Applet {
public void init() {
Label lab = new Label("A Red Label");
lab.setForeground(Color.red);
add(lab);
}
}
You can also set the Color for a Container and then all components added to that Container have use that Color.
Color is a class that encapsulates information about a color. You may create Color objects with RGB or HSV parameters, but a number of predefined colors (static variables) exist such as Color.red and Color.blue exist for your convenience.
Related Magercise(s):