在前面,我用多线程写了一个绘制了股票K线图的
程序.这里我再通过绘制一个成交量的统计图说明对鼠票事件的应用.这里我们要传入几个参数:
<applet code="sellhis.class" Archive="sellhis.jar" width="640" height="400">
<Param name="itemmonth" value="200201">
<Param name="itemcode" value="00002,00014,00019,00023,00041,00102,00113,00114,
00129,00132,00142,00146,00179,00203,00213,00223,00341">
<Param name="itemval" value="272950,193950,1015600,142700,1618500,671650,
2453300,630150,28375,1827660,7700,75700,27375,3375600,47500,17500,17500">
<Param name="itempce" value="219,156,817,114,2302,540,1974,507,22,
1471,6,60,22,4717,38,114,14">
</applet>
查看演示
sellhis.java源
程序如下:
import java.awt.*;
import java.applet.*;
import java.awt.font.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import java.util.*;
public class sellhis extends Applet{
static int Len;
int leftMargine=50;
int rightMargine=20;
int topMargine=80;
int buttomMargine=20;
int width,height,w,h;
int minStickLength=3; //坐标的短刻度
int majStickLength=8; //坐标的长刻度
int minStick=10;
int majStick;
String title;
String xTitle="股票代碼";
String xCode;
float yData,xPce;
String MaxPce;
boolean Mouse_Move;
int x0,y0,X,Y,hx,hy;
Label label=new Label;
boolean mouse_move=false;
public void init() {
width=this.getBounds().width;
height=this.getBounds().height;
w=width-leftMargine-rightMargine;
h=height-topMargine-buttomMargine;
setSize(width,height);
Color bc=new Color(229,229,229);
setBackground(bc);
setLayout(null);
for(int I=0;I<3;I++){
label[I]=new Label();
label[I].setForeground(Color.blue);
this.add(label[I]);
if(I==0)
label[I].reshape(75,topMargine-25,60,15);
if(I==1)
label[I].reshape(230,topMargine-25,80,15);
if(I==2)
label[I].reshape(505,topMargine-25,60,15);
}
try{
title=getTitle(getParameter("itemmonth"));
}
catch(Exception e){
System.out.println