41. jb5.addActionListener(this);
42.
43. tm=newTableModel();
44. jt=newJTable(tm);
45. jsp=newJScrollPane(jt);
46.
47. //jt.setBackground(Color.pink);
48. jt.setForeground(Color.black);
49. jt.setGridColor(Color.red);
50. this.add(jp1,BorderLayout.NORTH);
51. this.add(jp3,BorderLayout.SOUTH);
52. this.add(jsp);
53.
54.
55.
56.
57. this.setTitle("mini 学生管理系统");
58. this.setSize(400,300);
59. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
60. this.setVisible(true);
61. }
62. @Override
63. publicvoidactionPerformed(ActionEvente){
64. //TODOAuto-generatedmethodstub
65. if(e.getSource()==jb1){
66. Stringname=this.jtf.getText().trim();
67. if(name.equals("")){
68. JOptionPane.showMessageDialog(this,"请输入要查询的名字,
不可为空");
69. Stringsql="select*fromstu";
70. tm=newTableModel(sql);
71. jt.setModel(tm);
72. return;
73. }
74. Stringsql="select*fromstuwherestuName='"+name+"'";
75. tm=newTableModel(sql);
76. jt.setModel(tm);
77. }elseif(e.getSource()==jb5){
78. Stringsql="select*fromstu";
79. tm=newTableModel(sql);
80. jt.setModel(tm);
81. }elseif(e.getSource()==jb2){
82. AddInterfaceaddi=newAddInterface(this,"添加学生窗口",
true);
评论0
最新资源