A Trivial Applet Subclass
Base applet:
Class Applet
- is in java.applet package
- method 'init' is defined in java.applet.Applet class
- method 'paint' is defined in java.awt.Container class
Class Color
- is in java.awt package
- color constant examples: DARK_GRAY, BLACK, ORANGE, YELLOW
- constructors used:
- Color(ColorSpace cspace, float[] components, float alpha)
Creates a color in the specified ColorSpace with the color components specified in the float array and the specified alpha.
- Color(float r, float g, float b)
Creates an opaque sRGB color with the specified red, green, and blue values in the range (0.0 - 1.0).
- Color(float r, float g, float b, float a)
Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0.0 - 1.0).
- Color(int rgb)
Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.
- Color(int rgba, boolean hasalpha)
Creates an sRGB color with the specified combined RGBA value consisting of the alpha component in bits 24-31, the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.
- Color(int r, int g, int b)
Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255).
- Color(int r, int g, int b, int a)
Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).
Double width (100) and triple height (150):
Change color to DARK_GRAY:
Change color to (255,100,100):
* Change color after paint is invoked (changes the color of background):
|