secantapp中创建一个secantframe的实例,调用它的方法就行
也可以直接使用静态方法

解决方案 »

  1.   

    public class SecantFrame extends Frame implements ActionListener{
     double x1do,x2do,toldo; //double[] is ok
     int maxin;
     public double getX1(){
       return x1do;
     }
    ...
    }//
    win.getX1()
    ...
      

  2.   

    public void actionPerformed(ActionEvent e){
        String x1tr,x2tr,toltr,maxtr;
        Double x1do,x2do,toldo;
        Integer maxin;
          public double getX1(){
          return x1do;}
          public double getX2(){
          return x2do;}
          public double getX3(){
          return toldo;}
          public double getX4(){
          return maxin;}
         if (e.getSource()==b1){
            x1tr=x1.getText();
            x1do=Double.valueOf(x1tr);
      
            x2tr=x2.getText();
            x2do=Double.valueOf(x2tr);        toltr=tol.getText();
            toldo=Double.valueOf(toltr);        maxtr=max.getText();
            maxin=Integer.valueOf(maxtr);
           
          } 
    }
    import java.awt.*;
    public class SecantApp {public static void main(String args[]){
    SecantFrame win = new SecantFrame("");
    win.setVisible(true);
            Secant myEq= new MySecant(win.getX1(),win.getX2(),win.getX3(),win.getX4());
            myEq.solve();
    }
    }楼上的,是这样吗?编译出错啊
      

  3.   

    你就在SecantFrame里面处理,并且显示,不要传到SecantApp中。
      

  4.   

    怎样可以调用到abstract class Secant和class MySecant吗?
      

  5.   

    //把变量定义和方法定义提到外面。
    ...
    private String x1tr,x2tr,toltr,maxtr;
    private Double x1do,x2do,toldo;
    private Integer maxin;
    public double getX1()
    {
    return x1do;
    }
    public double getX2()
    {
    return x2do;
    }
    public double getX3()
    {
    return toldo;
    }
    public double getX4()
    {
    return maxin;
    }public void actionPerformed(ActionEvent e){     if (e.getSource()==b1){
            x1tr=x1.getText();
            x1do=Double.valueOf(x1tr);
      
            x2tr=x2.getText();
            x2do=Double.valueOf(x2tr);        toltr=tol.getText();
            toldo=Double.valueOf(toltr);        maxtr=max.getText();
            maxin=Integer.valueOf(maxtr);
           
          } 
    }
    import java.awt.*;
    public class SecantApp {public static void main(String args[]){
    SecantFrame win = new SecantFrame("");
    win.setVisible(true);
        Secant myEq= new MySecant(win.getX1(),win.getX2(),win.getX3(),win.getX4());
        myEq.solve();
    }
    }
      

  6.   

    还是有错误啊,老大
    .\SecantFrame.java:81: incompatible types
    found   : java.lang.Double
    required: double
            return x1do;
                   ^
    .\SecantFrame.java:85: incompatible types
    found   : java.lang.Double
    required: double
            return x2do;
                   ^
    .\SecantFrame.java:89: incompatible types
    found   : java.lang.Double
    required: double
            return toldo;
                   ^
    .\SecantFrame.java:93: incompatible types
    found   : java.lang.Integer
    required: int
            return maxin;
                   ^
    4 errors
      

  7.   

    什么意思啊??错误是不是说返回是java.lang.*类型的,但constructor MySecant(double,double,double,int),所以不符合啊?
    java.lang.Double和double有什么区别啊?
      

  8.   

    //改成如下就能编译通过了。
    ...
    private String x1tr,x2tr,toltr,maxtr;
    //private Double x1do,x2do,toldo;
    private double x1do,x2do,toldo;
    //private Integer maxin;
    private int maxin;
    ..
      

  9.   

    还是不行啊!!.\SecantFrame.java:102: incompatible types
    found   : java.lang.Double
    required: double
            x1do=Double.valueOf(x1tr);
                               ^
    .\SecantFrame.java:105: incompatible types
    found   : java.lang.Double
    required: double
            x2do=Double.valueOf(x2tr);
                               ^
    .\SecantFrame.java:108: incompatible types
    found   : java.lang.Double
    required: double
            toldo=Double.valueOf(toltr);
                                ^
    .\SecantFrame.java:111: incompatible types
    found   : java.lang.Integer
    required: int
            maxin=Integer.valueOf(maxtr);
                                 ^
    4 errors
      

  10.   

    改成:
    Double.parseDouble(x1tr);
    Double.parseDouble(x2tr);
    Double.parseDouble(toltr);
    Integer.ParseInt(maxtr);
      

  11.   

    does not work ar
    .\SecantFrame.java:102: cannot resolve symbol
    symbol  : method parseDouble (java.lang.String)
    location: class SecantFrame
            x1do=parseDouble(x1tr);
                 ^
    .\SecantFrame.java:105: cannot resolve symbol
    symbol  : method parseDouble (java.lang.String)
    location: class SecantFrame
            x2do=parseDouble(x2tr);
                 ^
    .\SecantFrame.java:108: cannot resolve symbol
    symbol  : method parseDouble (java.lang.String)
    location: class SecantFrame
            toldo=parseDouble(toltr);
                  ^
    .\SecantFrame.java:111: cannot resolve symbol
    symbol  : method parseInt (java.lang.String)
    location: class SecantFrame
            maxin=parseInt(maxtr);
                  ^
    4 errors