import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class UseJTable extends JFrame
{
public UseJTable()
{
super("学生信息表");
setSize(300,200);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent windowevent)
{
Window window=windowevent.getWindow();
window.dispose();
System.exit(0);
}
});
JTable jtable=new JTable(new String[][]
{
{"王军","24"},{"李庚","26"}
//{"张堂","25"},{"刘关","27"}
},
new String[]{"姓名","年龄"});
jtable.setRowHeight(25);//设置table每行的高度
jtable.setGridColor(Color.BLUE);
JScrollPane jScrollPane=new JScrollPane(jtable);
getContentPane().add(jScrollPane,BorderLayout.CENTER);
}
public static void main(String args[])
{
UseJTable st=new UseJTable();
st.setVisible(true);
}
}