你的points是什么?没有定义啊。应该是
Point[] points = new Point[10];
吧。

解决方案 »

  1.   

    修改了后还是不可以呀,能帮我具体修改一下吗?
    我不懂在point类中的字段,在DrawLine中不可以直接调用马?
    刚学不久,不懂呢
      

  2.   

    你的程序太乱!我试试改了一下!但我不知到应该输入什么合适的值!你告诉我一组!
    你先试试这个程序!可以运行拉!
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.util.Random;
    import java.awt.event.*;
    import java.lang.Double.*;
    /*
    <applet code=DrawLine width=600 height=500>
    </applet>
    */
     class Line
     {
       public static double getLineY(int n, double inputT, double inputTc){
          double t0 = (n - 5.0 / 4.0) * inputTc;
          double t1 = (n - 3.0 / 4.0) * inputTc;
          double t2 = (n - 1.0 / 4.0) * inputTc;
          if((inputT >= t0) && (inputT < t1)){
             uc = 1.0 - (inputT - t0) * 4.0 / inputTc;
          }
          if((inputT >= t1) && (inputT < t2)){
             uc = -1.0 + (inputT - t1) * 4.0 / inputTc;
          }
          return uc;
       }
       static double uc;
    } class Point{
       public Point(double xVal, double yVal){
          x = xVal;
          y = yVal;
       }
       public double getX(){
          return x;
       }
       public double getY(){
          return y;
       }
       public void setX(double inputX){
          x = inputX;
       }
       public void setY(double inputY){
          y = inputY;
       }
       public String toString(){
          return Double.toString(x);
       }
       public double x;
       public double y;
    }
    public class DrawLine extends JFrame{
       final int origX = 50;
       final int origY = 350;
       Point[] points = new Point[10];
       InputStreamReader reader;
       BufferedReader input ;
       String s;   double tc,b,tr,a;   public DrawLine(){
         JFrame jf=new  JFrame();
         jf.setTitle("SPWM(自然采样法)");
         jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         jf.setSize(500, 400);
         jf.setVisible(true);
         jf.show();
          reader = new InputStreamReader(System.in);
          input = new BufferedReader(reader);
       }
       public static void main(String[] args)throws IOException{
          DrawLine t=new DrawLine();        t.initGUI();
            t.paintt();
          //Point[] points = new Point[10];
        }   public  void initGUI() throws IOException{
         System.out.println("请输入三角波的周期(tc):");
         s = input.readLine();
         tc = new Double(s).doubleValue();
         System.out.println("请输入三角波的峰值(b):");
         s = input.readLine();
         b = new Double(s).doubleValue();
         System.out.println("请输入正炫波的周期(tr):");
         s = input.readLine();
         tr = new Double(s).doubleValue();
         System.out.println("请输入正炫波的调制度(a):");
         s = input.readLine();
         a = new Double(s).doubleValue();
         for(int i = 0 ; i <10 ; i++){
               points[i] = new Point(0.0, 0.0);
            }
            int j = 0;
            for(int n = 1; n <= 5; n ++ ){
              for(double t=(n-5.0/4.0)*tc; t < (n-1.0/4.0)*tc; t += 0.0001){
                 double sinVolume = a * Math.sin((2.0 * t * Math.PI)/tr);
                 double lineVolume = Line.getLineY(n, t, tc);
                 double sub = sinVolume - lineVolume;
                 if(Math.abs(sub)<=0.001){
                    points[j].setX(t);
                    j++;
                 }
              }
            }        for(int k = 0 ; k < points.length; k += 2){
               System.out.println("The time is " + points[k] + "-------" + points[k+1]);
            }   }   public void paintt(){
          //super.paint(g);
          Graphics g =this.getGraphics();      g.drawLine(this.origX - 25, this.origY, this.getWidth() - 100, this.origY);
          g.drawLine(this.origX, 50, this.origX, this.getHeight() - 25);      for(int i = 1; i < 10; i++){
             g.drawLine(origX + i * 30, this.origY - 10, origX + i * 30, this.origY);
             g.drawString(Double.toString(i/100.0), origX + i*30, this.origY + 20);
             g.drawLine(this.origX, this.origY - i * 30, this.origX + 10, this.origY - i*30);
             g.drawString(Integer.toString(i * 30), this.origX - 20, this.origY - i * 30);
          }
          //Double b;      for(int j = 0; j < 5;j++){
             g.drawLine(origX + (new Double(points[2*j].getX())).intValue(), 230, origX +(new Double(points[2*j+1].getX())).intValue(), 230);
          }
       }
    }
      

  3.   

    老大,你在DrawLine类中根本就没有定义point为Point对象,就直接使用?在编译时上哪儿找?不出错才怪!