日期:2014-05-20  浏览次数:20829 次

我这个pressok按钮应加到哪个循环呢?
我是想先按中断的按钮,然后在文本框输入数字,然后点pressok按钮 把文本框中的数值传递到shipSET[0].speedNaviK这个中。为什么实现不了呢 大家有明白的给指点下吗?
public class kaku extends JFrame{
  private static final long serialVersionUID = 1L;
  /** Simulation Basic Data **/
  private int maximumVESSELS = 16;
  private int simFIN = 300;// int simFIN = 11521 ; /** 8 Days **/
  private double dtMIN = 1.0; /** minute **/
  private double pi = 3.14159265358979323846;
  private double degToRAD = pi / 180.0;
  private ShipCondition[] shipSET;
  private Timer timer;
  private TimerTask task;
  private int clock;
  private MyPanel pnlMain;
  private JButton btnInterrupt;
  private JButton pressok;
  private JLabel label1;
  private JTextField textField1;
  private boolean movable = false;
   
  public kaku() {
  initialize();
  }
   
  private void initialize() {
  clock = 0;
  shipSET = new ShipCondition[maximumVESSELS];
  for( int i=0;i<maximumVESSELS;i++){
  shipSET[i] = new ShipCondition() ;
  }
  for( int is = 0 ; is < maximumVESSELS ; is++ ){
  shipSET[is].vesselID = is ;
  shipSET[is].metaWeightGOAL = 10.0 ;
  shipSET[is].goalSigA = 5.0 ;  
  shipSET[is].goalSigB = 1.0 ;  
  shipSET[is].metaWeightCONTRACT = 1.0 ;
  shipSET[is].contractSigA = 10.0 ;
  shipSET[is].contractSigB = 1.0 ;
  shipSET[is].metaWeightEXPAND = 1.0 ;
  shipSET[is].expandSigA = -10.0 ;
  shipSET[is].expandSigB = 1.0 ;
  shipSET[is].metaWeightClusterAVOID = 100.0 ;
  shipSET[is].clusterAvoidSigA = -10.0 ;
  shipSET[is].clusterAvoidSigB = 3.0 ;
  shipSET[is].decisionMD = 6.0 ;
  shipSET[is].dcpaJUDGE = 0.75 ;
  shipSET[is].headOnDEG = 50.0 ;
  shipSET[is].courseRadOLD = pi/2 ; /* Dummy */
  shipSET[is].speedKtOLD = 5.0 ;  
  shipSET[is].courseRadNOW = pi/2 ; /* Dummy */
  shipSET[is].speedKtNOW = 5.0 ;
  shipSET[is].courseNaviRAD = pi/2 ; /* Dummy */
  shipSET[is].speedNaviKT = 5.0 ;
  shipSET[is]. goalRad=pi/2;
  }
   
double shipRad=360.0/((double)maximumVESSELS-1)*degToRAD;
 for(int i=1;i<maximumVESSELS;i++){

shipSET[i].xMileOLD = shipSET[0].xMileOLD+2.0*Math.cos(shipRad*(double)i) ; 
shipSET[i].yMileOLD = shipSET[0].yMileOLD+2.0*Math.sin(shipRad*(double)i) ; 
shipSET[i].xMileNOW =shipSET[0].xMileNOW+2.0*Math.cos(shipRad*(double)i) ; 
shipSET[i].yMileNOW = shipSET[0].yMileNOW+2.0*Math.sin(shipRad*(double)i) ; 

}
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  this.setSize(300, 300);
  Container cont = this.getContentPane();
  cont.setLayout(new BorderLayout());
  DocumentListener listener = new ClockFieldListener();  
  pnlMain = new MyPanel();

  pnlMain.add(new JLabel("shiprad"));
textField1=new JTextField(10);
pnlMain.add(textField1);
// textField1.addT
textField1.getDocument().addDocumentListener(listener);
pressok=new JButton("pressok");
pressok.addActionListener(new ActionListener()
{