第二个被调用的窗口程序:

/* 
author:YuGuichun 
fuction:student information manage 
time:2011.5.28 
*/ 
import javax.swing.*; 
 
import java.awt.*; 
import java.awt.event.*; 
import java.util.Iterator; 
import java.util.Vector; 
public class SmainFrame extends JFrame  
{  
      private JTextField number1,number2,number3,number4; 
      private ok ok1; 
      private cancel cancel1; 
       
      public SmainFrame() 
      { 
          
         super("学生成绩查询系统"); 
         setSize(300,200); 
        // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
         setVisible(true); 
         Container pane=getContentPane(); 
         FlowLayout flo=new FlowLayout(); 
         pane.setLayout(flo); 
          
          
         JLabel snumber1=new JLabel("输入姓名:",JLabel.CENTER); 
          number1=new JTextField(15); 
         JLabel sumber2=new JLabel("输入学号:",JLabel.CENTER); 
          number2=new JTextField(15); 
         JLabel snumber3=new JLabel("输入性别:",JLabel.CENTER); 
          number3=new JTextField(15); 
         JLabel snumber4=new JLabel("出生日期:",JLabel.CENTER); 
         number4=new JTextField(15); 
          
         JButton ok = new JButton("确定"); 
         JButton cancel = new JButton("取消"); 
          
         pane.add(snumber1); 
         pane.add(number1); 
         pane.add(sumber2); 
         pane.add(number2); 
         pane.add(snumber3); 
         pane.add(number3); 
         pane.add(snumber4); 
         pane.add(number4); 
          
         pane.add(ok); 
         pane.add(cancel); 
         ok ok2=new ok(); 
         cancel cancel2=new cancel(); 
         ok.addActionListener(ok2); 
         cancel.addActionListener(cancel2); 
             
         setContentPane(pane); 
         setVisible(true); 
     } 
       
     private class ok implements ActionListener 
     { 
         public void actionPerformed(ActionEvent e) 
         { 
         String name=number1.getText(); 
         String number=number2.getText(); 
         String sex=number3.getText(); 
         String brithdate=number4.getText(); 
        // Work7_8 A=new Work7_8(); 
         Student s1=new Student(); 
         s1.setAll(name,Integer.parseInt(number),sex,Integer.parseInt(brithdate)); 
         number1.setText(null); 
         number2.setText(null); 
         number3.setText(null); 
         number4.setText(null); 
         allVector V=new allVector(); 
         V.addVector(s1);//这里应该会出错的,等下改改 
          
          
        /*if(V.vector.isEmpty()) 
            JOptionPane.showMessageDialog(null, "vector is empty"); 
        else  
            
                String out="name    sex      num      age"+"\n"; 
                Iterator<Student> items=V.vector.iterator(); 
                while(items.hasNext()) 
                
                    Student s2=items.next(); 
                ] ]>

posted on 2011-05-28 21:47  cchun  阅读(1607)  评论(3编辑  收藏  举报