Professional Documents
Culture Documents
1 2
g.drawLine(x1,y1,x2,y2)
g.drawLine(x,y,width,height)
g.drawLine(10,10,50,50);
fillOval() g.drawRoundRect(10,100,80,50,10,10);
fillPolygon() g.fillRoundRect(20,110,60,30,5,5);
fillRect() g.drawLine(100,10,230,140);
fillRoundRect() g.drawLine(100,140,230,10);
getFont
}
setFont
More at http:/ /java.sun.com/ products/ jdk/ 1.2/ docs/ api/ java/ awt/ Graphics.html 3 4
180 0
180
5 6
Drawing a Happy Face Applet - Output!
import java.awt.* ;
import java.applet.* ;
7 8
9 10
11 12
Bar chart applet program… Bar chart applet program.
import java.awt.* ;
public void paint(Graphics g)
import java.applet.* ;
{
int n= 0;
String label[ ] ;
for(int i= 0;i< n;i+ + )
int value[ ] ;
public void init()
{
{
g.setColor(Color.red);
try
{
g.drawString(label[ i],20,i* 50+ 30);
n= I nteger.parseI nt(getParameter("columns"));
label[ 0] = getParameter("label1");
label[ 1] = getParameter("label2");
label[ 2] = getParameter("label3");
}
label[ 3] = getParameter("label4"); }
value[ 0] = I nteger.parseI nt(getParameter("c1"));
}
} catch(NumberFormatException e){ }
}
13 14
< HTML>
< APPLET
CODE= BarChart.class
WI DTH= 300
HEI GHT= 250>
Summary
17