肯定程序代码的问题!黏上来看看!

解决方案 »

  1.   

    class scs1{.....}public class quxian extends Applet implements ItemListener,ActionListener,Runnable
    {
    scs1 dbcon;
    Button button1;
    Choice choice1;
    Label label1;
    Vector vector1;
    String text;
    Thread xianchen1=null;
    int flag1=1;int flag2=1;
    int biaozhi=0;
    int canshuzhi=0;
    int sb=0;
    int shuzu[];
    int x1,x2,y1,y2;public void init(){
    setLayout(null);
    button1=new Button();
    choice1= new Choice();
    label1=new Label();
    add(label1);
    add(button1);
    add(choice1);
    choice1.addItemListener(this);
    button1.addActionListener(this);
    label1.setBounds(300,10,200,10);
    choice1.setBounds(100,240,50,50);
    button1.setBounds(400,240,50,50);
    shuzu=new int[400];}public void start(){
    if(xianchen1==null);
    {xianchen1=new Thread(this);
    xianchen1.start();
    }}public void stop(){}
    public void run(){
    dbcon=new scs1();
    dbcon.dbConnection();
    vector1=dbcon.results;
    Enumeration enum=vector1.elements();
    text=((String)enum.nextElement()).trim();repaint();if(text.equals(message)){
    flag2=1;
    choice1.add("");
    choice1.add("温");
    choice1.add("锅");
    choice1.add("炉");}
    else{
    choice1.add("");
    choice1.add("温x1");
    choice1.add("锅x1");
    choice1.add("炉x1");
    flag2=2;}while(true){dbcon.canshuhao=canshuzhi;
    dbcon.n=biaozhi;
    dbcon.dbConnection();
    vector1=dbcon.results;
    repaint();
    biaozhi++;
    try{xianchen1.sleep(2000);}
    catch(Exception sleepproblem){}
    }
    }public void itemStateChanged(ItemEvent e){
    canshuzhi++;
    biaozhi=0;
    }
    public void actionPerformed(ActionEvent e)
    {}public void paint(Graphics g) 
    {
    if (biaozhi<=4){
    Enumeration enum=vector1.elements();
    while(enum.hasMoreElements()){
    String s=(String)enum.nextElement();
    float temp1=Float.parseFloat(s);
    int temp=(int)temp1;
    shuzu[sb]=temp;
    sb++;
    }
    if(biaozhi==1){
    for(i=0;i<99;i++){
    x1=480-i;
    x2=480-(i+1);
    y1=20*(550-shuzu[i]);
    y2=20*(550-shuzu[i+1]);
    g.drawLine(x1,y1,x2,y2);}}
    else if(biaozhi==2){
    for(i=0;i<199;i++){
    x1=480-i;
    x2=480-(i+1);
    y1=20*(550-shuzu[i]);
    y2=20*(550-shuzu[i+1]);
    g.drawLine(x1,y1,x2,y2);}}
    else if(biaozhi==3){
    for(i=0;i<299;i++){
    x1=480-i;
    x2=480-(i+1);
    y1=20*(550-shuzu[i]);
    y2=20*(550-shuzu[i+1]);
    g.drawLine(x1,y1,x2,y2);}}
    else if(biaozhi==4){
    for(i=0;i<399;i++){
    x1=480-i;
    x2=480-(i+1);
    y1=20*(550-shuzu[i]);
    y2=20*(550-shuzu[i+1]);
    g.drawLine(x1,y1,x2,y2);}}

    else if(biaozhi>4){
    for(i=100;i<400;i++){
    shuzu[i-100]=shuzu[i];}
    Enumeration enum=vector1.elements();
    int k=300;
    while(enum.hasMoreElements()){
    String s=(String)enum.nextElement();
    float temp1=Float.parseFloat(s);
    int temp=(int)temp1;
    shuzu[k]=temp;
    k++;}
    for(i=0;i<399;i++){
    x1=20+i;
    x2=20+(i+1);
    y1=20*(550-shuzu[i]);
    y2=20*(550-shuzu[i+1]);
    g.drawLine(x1,y1,x2,y2);}}
    /*Enumeration enum=vector1.elements();
    String s=(String)enum.nextElement();
    float temp1=Float.parseFloat(s);
    int temp=(int)temp1;
    String temp2=String.valueOf(temp);
    g.drawString(temp2,200,200);*/
    }
    }