在网上很难找到做报表用的各种用图。下面是我最近的新作。一点点小东西,
与大家分享,如果有什么问题请发信到[email protected]
applet 原码,用jcreator打开即可。
import java.awt.*;
import java.applet.*;
public class square extends Applet
{
private int data[], dataAll, dataArc[], i;
Thread m_MultiThread;
public square(){}
// the init function ;
public void init()
{
data=new int[10];
dataArc=new int[10];
data[0]=100;
data[1]=150;
data[2]=60;
data[3]=30;
data[4]=20;
data[5]=60;
data[6]=200;
data[7]=600;
data[8]=210;
data[9]=10;
while(i<10)
{
dataAll+=data[i++];
}
}
file://tho body of paint;
public void paint(Graphics g )
{
Font f1=new Font("Verdana",Font.BOLD,25);
g.setFont(f1);
g.drawRect(15,0,570,250);
g.drawString("the product of last year",150,35);
g.drawLine(40,225,550,225);
g.setColor(Color.ORANGE);
Font f2=new Font("Verdana",Font.BOLD,12);
g.setFont(f2);
for(i=0;i<=9;i++)
{
g.fillRect(50+i*50,225-data[i]/4,45,data[i]/4);
g.drawString(data[i]+"",50+i*50+10,220-data[i]/4);
g.drawString(i+1+"M",50+i*50,240);
}
}
}
html原码如下:
<html>
<head>
<title>bars</title>
</head>
<body>
<applet code=square.class width=800 height=500 >
</applet>
</body>
</html>
结果如下:
本文地址:http://com.8s8s.com/it/it16927.htm