网站首页 新闻首页 网页设计图形动画软件编程网站开发办公软件操作系统数据库网络技术认证考试范文资料黑客攻防 书籍教程 进入论坛

用Java绘制K线 (转2)

http://www.diybl.com/ 2007-2-6  网络 点击:  [ 评论 ]
文章搜索:    【点击打包该文章】

---- 附:StockApplet.java

import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
public class StockApplet extends java.applet.Applet implements Runnable
{ //以下是公用变量的声明部分
    int Move_Length=0,Move_Sum=0;
    String FileName,Name_Str,Content_Date;
    int SP[]=new int[2000];
    int KP[]=new int[2000];
    int JD[]=new int[2000];
    int JG[]=new int[2000];
    int Mid_Worth[]=new int[2000];
    String myDate[]=new String[2000];
    double CJL[]=new double[2000];
    double MaxCJL,MidCJL;
    Label label[]=new Label[10];
    int MaxWorth,MinWorth;
int x_move0,x_move1,MaxLength=0;
    int x0,y0,X,Y,Record_Num;
    boolean Mouse_Move,Name_Change=true;
    int JX_Five1,JX_Five2,JX_Ten1,JX_Ten2;
public void init()
{
  TextField text1=new TextField();
  Thread M_pointThread=null;
      setLayout(null);                  //声明布局管理器
      this.setBackground(Color.white);    //设置背景色
  this.setForeground(Color.black);     //设定文字颜色
      for(int i=1;i< 10;i++)      //以下循环用于向布局中添加标签
      {
        label[i]=new Label();
        this.add(label[i]);
        label[i].reshape(i*80-65,10,50,15);
        if(i==2){label[i].reshape(80,10,70,15);}
        if(i==7){label[i].reshape(510,10,80,15);}
        if(i >7){label[i].reshape((i-8)*490+45,380,70,15);}
      }
      FileName="000001";        //程序启动时的默认股票代码
      Name_Str="上证指数";
      this.add(text1);             //向布局中添加文本框
      text1.reshape(150,385,70,20);
      text1.getText();             //取得文本框中输入的内容
}
public void start()
{    //创建并启动多线程
    if (M_pointThread==null)
    {
        M_pointThread=new Thread(this);
        M_pointThread.start();
    }
}
public void run()
{    //运行多线程
    Graphics M_graphics;
    M_graphics=getGraphics();
    M_graphics.setXORMode(Color.white);
    while(true)  //绘制“十字”游标
    {
        try
        {
            if(Mouse_Move==true)
            {
                if(x0 >50 & x0< 600){M_graphics.drawLine(x0,30,x0,380);}
                if(y0 >30 & y0< 380){M_graphics.drawLine(50,y0,600,y0);}
                if(X >50 & X< 600){M_graphics.drawLine(X,30,X,380);}
                if(Y >30 & Y< 380){M_graphics.drawLine(50,Y,600,Y);}
                Mouse_Move=false;
                x0=X;
                y0=Y;
            }
        }catch(NullPointerException npe){}
    }
}
public boolean action(Event evt,Object arg)   //监测事件
    {
        FileName=text1.getText();    //取得新文件名
        repaint();
     //将各变量恢复初始状态
        Name_Change=true;
        Move_Length=0;
        Move_Sum=0;
        MaxLength=0;
        MaxCJL=0;
        return true;
    }
public boolean keyDown(Event evt,int key)  //检测键盘事件
    {
       

欢迎光临DIY部落,点击这里查看更多文章教程   【点击打包该文章】
如果图片或页面不能正常显示请点击这里 站内搜索:   

文章评论

请您留言