哥哥姐姐,帮帮我看看什么怎么回事
编译可以但是解释执行就不可以了import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import *;
import *;
public class deleteRows extends JFrame implements ActionListener
{
private int rows = 0,cols = 0,num = 0;
private Object rowdata[] = new Object[cols];
private DefaultTableModel model = new DefaultTableModel();
private JTable table = new JTable(model);
private JTextField jtext = new JTextField(5);
private JButton rowbutton = new JButton("Add Row");
private JButton delbutton = new JButton("Del Row");
public deleteRows()
{
setTitle("行的添加和删除举例");
Container cp = getContentPane();
JPanel panel1 = new JPanel();
panel1.add(rowbutton);
panel1.add(delbutton);
JPanel panel2 = new JPanel();
panel2.add(new JLabel("请输入要删除的学号"));
panel2.add(jtext);
model.addColumn("学号");
model.addColumn("姓名");
model.addColumn("学院");
model.addColumn("班级");
cp.add(new JScrollPane(table),BorderLayout.CENTER);
cp.add(panel1,BorderLayout.SOUTH);
cp.add(panel2,BorderLayout.NORTH);
rowbutton.addActionListener(this);
delbutton.addActionListener(this);
setSize(300,200);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == rowbutton)
{
int rowCount = model.getRowCount();
rowdata = new Object[cols];
rowdata[0] = "A00"+(num+1);
for (int c=1;c<cols ;++c )
{
rowdata[c] = "table["+rowCount+"]["+c+"]";
}
model.insertRow(num,rowdata);
num++;
}
if (e.getSource() == delbutton)
{
String str = jtext.getText();
int k = 0;
while (k<model.getRowCount())
{
if (str.equals((model.getValueAt(k,0)).toString()))
{
model.removeRow(k);
break;
}
k++;
}
}
}
public static void main(String args[])
{
new deleteRows();
}
}