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

问点小问题!
package frame;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;




public class insert extends JPanel implements ActionListener {
 
 
 

 
//JFrame frame;
JPanel panel1;
JPanel panel4;
JPanel panel2;
JPanel panel3;
JPanel panel;
JLabel label1;
JLabel label2;
JLabel label3;
JLabel label4;
JLabel label5;
JTextField text1;
JTextField text2;
JTextField text3;
JTextField text4;
JTextField text5;
JComboBox com;
JButton button1;
JButton button3;
JButton button2;
JButton button4;
JButton button5;



 

public insert() {

//frame.setVisible(false);
panel3=new JPanel();
panel1=new JPanel();
panel2=new JPanel();
panel4=new JPanel();
label1=new JLabel("学号");
label2=new JLabel("姓名");
label3=new JLabel("班级");
label4=new JLabel("电话");
label5=new JLabel("家庭住址");
text1=new JTextField(10);
text1.addActionListener(this);
text2=new JTextField(5);
text3=new JTextField(5);
text4=new JTextField(10);
text5=new JTextField(20);
com=new JComboBox();
button1=new JButton("完成");
button3=new JButton("清空");
button2=new JButton("取消");
button2.addActionListener(this);
button4=new JButton("存入");
button4.addActionListener(this);
button5=new JButton("清空");

button5.addActionListener(this);

com.addItem("男");
com.addItem("女");

this.setLayout(new GridLayout(3,8));
panel1.add(label1);
panel1.add(text1);
panel1.add(label2);
panel1.add(text2);
panel1.add(com);
panel1.add(label3);
panel1.add(text3);
panel1.add(label4);
panel1.add(text4);
panel1.add(label5);
panel1.add(text5);
panel1.add(button4);
panel1.add(button5);
panel3.add(new Table3(null));

panel2.add(button1);
panel2.add(button3);
panel2.add(button2);
this.add(panel1);
this.add(panel3);
this.add(panel2);

this.setSize(800,600);
  this.setLocation(300,100);
this.setVisible(true);

//button1.addActionListener(new show());



}






public void actionPerformed(ActionEvent arg0) {
//事件的触发
if(arg0.getSource()==text1)
{


}

if(arg0.getSource()== button4)
{  


panel3.removeAll();
panel3.add(new Table3(text1.getText()));

panel3.updateUI();








}



if(arg0.getSource()==button5)
{
text1.setText("");