COLOR defines several constant such as Color.red as we use in this tutorial and we can also create
color by color constructors.The most common constructor are:
- Color(int red,int green,int blue) in this tutorial we use this constructor.
- Color(int rgbValue).
- Color(float red,float green,float blue).
HTML CODE OF APPLET:
<html>
<body>
<applet code="colorapp" width="300" height="300">
</applet>
</body>
</html>
JAVA CODING:
import java.applet.*;import java.awt.*;
public class colorapp extends Applet{
public void paint(Graphics g){
Color c2 = new Color(100,255,100);
Color c3 = new Color(100,100,255);
g.setColor(c2);
g.fillRoundRect(70,90,140,100,30,40);
g.setColor(c3);
g.fillOval(70,90,140,100);
g.setColor(Color.red);
g.drawString("Pro java tricks",90,130);
setBackground(Color.red);
}
}
No comments:
Post a Comment