基于java swing+mysql实现学生信息管理系统:主要实现jdbc对学生信息进行增删改查,应付一般课设足矣,分享给大家。(由于篇幅原因,代码未全部列出,如有需要留下邮箱)
鉴于太多同学要源码,实在发不过来,上传到github上 https://github.com/zhuangm/student.git
1、 开发环境:jdk7+mysql5+win7
代码结构:model-dao-view
2、 数据库设计--建库建表语句:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
create database student; drop table if exists `admin`; create table `admin` ( `id` int ( 11 ) not null auto_increment, `name` varchar( 20 ) not null , `username` varchar( 20 ) not null , `password` varchar( 20 ) not null , primary key (`id`) ) engine=innodb auto_increment= 2 default charset=utf8; lock tables `admin` write; insert into `admin` values ( 1 , 'admin' , 'admin' , 'admin' ); unlock tables; drop table if exists `student`; create table `student` ( `id` int ( 11 ) not null auto_increment, `name` varchar( 20 ) not null , `sno` varchar( 20 ) not null , `department` varchar( 20 ) not null , `hometown` varchar( 20 ) not null , `mark` varchar( 20 ) not null , `email` varchar( 20 ) not null , `tel` varchar( 20 ) not null , `sex` varchar( 20 ) not null , primary key (`id`) ) engine=innodb auto_increment= 22 default charset=utf8; lock tables `student` write; insert into `student` values ( 18 , '张三' , '001' , '信息科学技术学院' , '辽宁' , '80' , 'zhangsan@163.com' , '13888888888' , '男' ),( 19 , '李四' , '002' , '理学院' , '上海' , '70' , 'lisi@sina.com' , '13812341234' , '男' ),( 20 , '王五' , '003' , '外国语学院' , '北京' , '88' , 'wangwu@126.com' , '13698765432' , '女' ); unlock tables; |
3、model--管理员、学生
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/** * 项目名:student * 修改历史: * 作者: mz * 创建时间: 2016年1月6日-上午9:42:48 */ package com.student.model; /** * 模块说明:admin * */ public class admin { private int id; private string name; private string username; private string password; public string getname() { return name; } public void setname(string name) { this .name = name; } public int getid() { return id; } public void setid( int id) { this .id = id; } public string getusername() { return username; } public void setusername(string username) { this .username = username; } public string getpassword() { return password; } public void setpassword(string password) { this .password = password; } } |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/** * 项目名:student * 修改历史: * 作者: mz * 创建时间: 2016年1月6日-上午9:42:36 */ package com.student.model; /** * 模块说明: 学生 * */ public class student { private int id; private string sno; // 学号 private string name; private string sex; private string department; // 院系 private string hometown; // 籍贯 private string mark; // 学分 private string email; private string tel; // 联系方式 public int getid() { return id; } public void setid( int id) { this .id = id; } public string getsno() { return sno; } public void setsno(string sno) { this .sno = sno; } public string getname() { return name; } public void setname(string name) { this .name = name; } public string getsex() { return sex; } public void setsex(string sex) { this .sex = sex; } public string getdepartment() { return department; } public void setdepartment(string department) { this .department = department; } public string gethometown() { return hometown; } public void sethometown(string hometown) { this .hometown = hometown; } public string getmark() { return mark; } public void setmark(string mark) { this .mark = mark; } public string getemail() { return email; } public void setemail(string email) { this .email = email; } public string gettel() { return tel; } public void settel(string tel) { this .tel = tel; } } |
4、 工具类dbutil(对jdbc进行封装)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/** * 项目名:student * 修改历史: * 作者: mz * 创建时间: 2016年1月6日-上午9:43:21 */ package com.student.util; import java.sql.connection; import java.sql.drivermanager; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import com.student.appconstants; /** * 模块说明:数据库工具类 * */ public class dbutil { private static dbutil db; private connection conn; private preparedstatement ps; private resultset rs; private dbutil() { } public static dbutil getdbutil() { if (db == null ) { db = new dbutil(); } return db; } public int executeupdate(string sql) { int result = - 1 ; if (getconn() == null ) { return result; } try { ps = conn.preparestatement(sql); result = ps.executeupdate(); } catch (sqlexception e) { e.printstacktrace(); } return result; } public int executeupdate(string sql, object[] obj) { int result = - 1 ; if (getconn() == null ) { return result; } try { ps = conn.preparestatement(sql); for ( int i = 0 ; i < obj.length; i++) { ps.setobject(i + 1 , obj[i]); } result = ps.executeupdate(); close(); } catch (sqlexception e) { e.printstacktrace(); } return result; } public resultset executequery(string sql) { if (getconn() == null ) { return null ; } try { ps = conn.preparestatement(sql); rs = ps.executequery(); } catch (sqlexception e) { e.printstacktrace(); } return rs; } public resultset executequery(string sql, object[] obj) { if (getconn() == null ) { return null ; } try { ps = conn.preparestatement(sql); for ( int i = 0 ; i < obj.length; i++) { ps.setobject(i + 1 , obj[i]); } rs = ps.executequery(); } catch (sqlexception e) { e.printstacktrace(); } return rs; } private connection getconn() { try { if (conn == null || conn.isclosed()) { class .forname(appconstants.jdbc_driver); conn = drivermanager.getconnection(appconstants.jdbc_url, appconstants.jdbc_username, appconstants.jdbc_password); } } catch (classnotfoundexception e) { system.out.println( "jdbc driver is not found." ); e.printstacktrace(); } catch (sqlexception e) { e.printstacktrace(); } return conn; } public void close() { try { if (rs != null ) { rs.close(); } if (ps != null ) { ps.close(); } if (conn != null ) { conn.close(); } } catch (sqlexception e) { e.printstacktrace(); } } } |
5、 dao:主要调用dbutil操作相应的model--增删改查
basedao.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/** * 项目名:student * 修改历史: * 作者: mz * 创建时间: 2016年1月6日-上午10:04:37 */ package com.student.base; import java.sql.resultset; import java.sql.sqlexception; import com.student.dao; import com.student.dao.admindao; import com.student.dao.studentdao; import com.student.util.dbutil; /** * 模块说明: dao基类 * */ public abstract class basedao { protected final dbutil db = dbutil.getdbutil(); protected resultset rs; private static basedao basedao; public basedao() { init(); } private void init() { // buildabilitydao(); } // protected abstract void buildabilitydao(); public static synchronized basedao getabilitydao(dao dao) { switch (dao) { case admindao: if (basedao == null || basedao.getclass() != admindao. class ) { basedao = admindao.getinstance(); } break ; case studentdao: if (basedao == null || basedao.getclass() != studentdao. class ) { basedao = studentdao.getinstance(); } break ; default : break ; } return basedao; } protected void destroy() { try { if (rs != null ) { rs.close(); } } catch (sqlexception se) { se.printstacktrace(); } finally { db.close(); } } } |
admindao.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/** * 项目名:student * 修改历史: * 作者: mz * 创建时间: 2016年1月6日-上午9:59:58 */ package com.student.dao; import java.sql.sqlexception; import com.student.base.basedao; /** * 模块说明: 管理员增删改查 * */ public class admindao extends basedao { private static admindao ad = null ; public static synchronized admindao getinstance() { if (ad == null ) { ad = new admindao(); } return ad; } public boolean queryforlogin(string username, string password) { boolean result = false ; if (username.length() == 0 || password.length() == 0 ) { return result; } string sql = "select * from admin where username=? and password=?" ; string[] param = { username, password }; rs = db.executequery(sql, param); try { if (rs.next()) { result = true ; } } catch (sqlexception e) { e.printstacktrace(); } finally { destroy(); } return result; } } |
studentdao.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
/** * 项目名:student * 修改历史: * 作者: mz * 创建时间: 2016年1月6日-上午10:00:07 */ package com.student.dao; import java.sql.resultset; import java.sql.sqlexception; import java.util.arraylist; import java.util.list; import com.student.base.basedao; import com.student.model.student; /** * 模块说明: 学生增删改查 * */ public class studentdao extends basedao { private final int fieldnum = 9 ; private final int shownum = 15 ; private static studentdao sd = null ; public static synchronized studentdao getinstance() { if (sd == null ) { sd = new studentdao(); } return sd; } // update public boolean update(student stu) { boolean result = false ; if (stu == null ) { return result; } try { // check if (querybysno(stu.getsno()) == 0 ) { return result; } // update string sql = "update student set sex=?,department=?,email=?,tel=?,hometown=?,mark=? where name=? and sno=?" ; string[] param = { stu.getsex(), stu.getdepartment(), stu.getemail(), stu.gettel(), stu.gethometown(), stu.getmark(), stu.getname(), stu.getsno() }; int rowcount = db.executeupdate(sql, param); if (rowcount == 1 ) { result = true ; } } catch (sqlexception se) { se.printstacktrace(); } finally { destroy(); } return result; } // delete public boolean delete(student stu) { boolean result = false ; if (stu == null ) { return result; } string sql = "delete from student where name=? and sno=?" ; string[] param = { stu.getname(), stu.getsno() }; int rowcount = db.executeupdate(sql, param); if (rowcount == 1 ) { result = true ; } destroy(); return result; } // add public boolean add(student stu) { boolean result = false ; if (stu == null ) { return result; } try { // check if (querybysno(stu.getsno()) == 1 ) { return result; } // insert string sql = "insert into student(name,sno,sex,department,hometown,mark,email,tel) values(?,?,?,?,?,?,?,?)" ; string[] param = { stu.getname(), stu.getsno(), stu.getsex(), stu.getdepartment(), stu.gethometown(), stu.getmark(), stu.getemail(), stu.gettel() }; if (db.executeupdate(sql, param) == 1 ) { result = true ; } } catch (sqlexception se) { se.printstacktrace(); } finally { destroy(); } return result; } // query by name public string[][] querybyname(string name) { string[][] result = null ; if (name.length() < 0 ) { return result; } list<student> stus = new arraylist<student>(); int i = 0 ; string sql = "select * from student where name like ?" ; string[] param = { "%" + name + "%" }; rs = db.executequery(sql, param); try { while (rs.next()) { buildlist(rs, stus, i); i++; } if (stus.size() > 0 ) { result = new string[stus.size()][fieldnum]; for ( int j = 0 ; j < stus.size(); j++) { buildresult(result, stus, j); } } } catch (sqlexception se) { se.printstacktrace(); } finally { destroy(); } return result; } // query public string[][] list( int pagenum) { string[][] result = null ; if (pagenum < 1 ) { return result; } list<student> stus = new arraylist<student>(); int i = 0 ; int beginnum = (pagenum - 1 ) * shownum; string sql = "select * from student limit ?,?" ; integer[] param = { beginnum, shownum }; rs = db.executequery(sql, param); try { while (rs.next()) { buildlist(rs, stus, i); i++; } if (stus.size() > 0 ) { result = new string[stus.size()][fieldnum]; for ( int j = 0 ; j < stus.size(); j++) { buildresult(result, stus, j); } } } catch (sqlexception se) { se.printstacktrace(); } finally { destroy(); } return result; } // 将rs记录添加到list中 private void buildlist(resultset rs, list<student> list, int i) throws sqlexception { student stu = new student(); stu.setid(i + 1 ); stu.setname(rs.getstring( "name" )); stu.setdepartment(rs.getstring( "department" )); stu.setemail(rs.getstring( "email" )); stu.sethometown(rs.getstring( "hometown" )); stu.setmark(rs.getstring( "mark" )); stu.setsex(rs.getstring( "sex" )); stu.setsno(rs.getstring( "sno" )); stu.settel(rs.getstring( "tel" )); list.add(stu); } // 将list中记录添加到二维数组中 private void buildresult(string[][] result, list<student> stus, int j) { student stu = stus.get(j); result[j][ 0 ] = string.valueof(stu.getid()); result[j][ 1 ] = stu.getname(); result[j][ 2 ] = stu.getsno(); result[j][ 3 ] = stu.getsex(); result[j][ 4 ] = stu.getdepartment(); result[j][ 5 ] = stu.gethometown(); result[j][ 6 ] = stu.getmark(); result[j][ 7 ] = stu.getemail(); result[j][ 8 ] = stu.gettel(); } // query by sno private int querybysno(string sno) throws sqlexception { int result = 0 ; if ( "" .equals(sno) || sno == null ) { return result; } string checksql = "select * from student where sno=?" ; string[] checkparam = { sno }; rs = db.executequery(checksql, checkparam); if (rs.next()) { result = 1 ; } return result; } } |
6、 view:与用户交互的界面(包括loginview.java、mainview.java、addview.java、deleteview.java、updateview.java),主要使用dao提供的接口,由于篇幅原因,仅列出mainview即首页。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
/** * 项目名:student * 修改历史: * 作者: mz * 创建时间: 2016年1月6日-下午1:37:39 */ package com.student.view; import java.awt.borderlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.keyadapter; import java.awt.event.keyevent; import javax.swing.jbutton; 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; import com.student.appconstants; import com.student.dao; import com.student.base.basedao; import com.student.dao.studentdao; /** * 模块说明: 首页 * */ public class mainview extends jframe { private static final long serialversionuid = 5870864087464173884l; private final int maxpagenum = 99 ; private jpanel jpanelnorth, jpanelsouth, jpanelcenter; private jbutton jbuttonfirst, jbuttonlast, jbuttonnext, jbuttonpre, jbuttonadd, jbuttondelete, jbuttonupdate, jbuttonfind; private jlabel currpagenumjlabel; private jtextfield condition; public static jtable jtable; private jscrollpane jscrollpane; private defaulttablemodel mytablemodel; public static string[] column = { "id" , appconstants.student_name, appconstants.student_sno, appconstants.student_sex, appconstants.student_departmetn, appconstants.student_hometown, appconstants.student_mark, appconstants.student_email, appconstants.student_tel }; public static int currpagenum = 1 ; public mainview() { init(); } private void init() { settitle(appconstants.mainview_title); // north panel jpanelnorth = new jpanel(); jpanelnorth.setlayout( new gridlayout( 1 , 5 )); condition = new jtextfield(appconstants.param_find_condition); condition.addkeylistener( new findlistener()); jpanelnorth.add(condition); // query by name jbuttonfind = new jbutton(appconstants.param_find); jbuttonfind.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { find(); } }); jbuttonfind.addkeylistener( new findlistener()); // add jpanelnorth.add(jbuttonfind); jbuttonadd = new jbutton(appconstants.param_add); jbuttonadd.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { new addview(); } }); jpanelnorth.add(jbuttonadd); // delete jbuttondelete = new jbutton(appconstants.param_delete); jbuttondelete.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { new deleteview(); } }); jpanelnorth.add(jbuttondelete); // update jbuttonupdate = new jbutton(appconstants.param_update); jbuttonupdate.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { new updateview(); } }); jpanelnorth.add(jbuttonupdate); // center panel jpanelcenter = new jpanel(); jpanelcenter.setlayout( new gridlayout( 1 , 1 )); // init jtable string[][] result = ((studentdao) basedao.getabilitydao(dao.studentdao)).list(currpagenum); mytablemodel = new defaulttablemodel(result, column); jtable = new jtable(mytablemodel); defaulttablecellrenderer cr = new defaulttablecellrenderer(); cr.sethorizontalalignment(jlabel.center); jtable.setdefaultrenderer(object. class , cr); initjtable(jtable, result); jscrollpane = new jscrollpane(jtable); jpanelcenter.add(jscrollpane); // south panel jpanelsouth = new jpanel(); jpanelsouth.setlayout( new gridlayout( 1 , 5 )); jbuttonfirst = new jbutton(appconstants.mainview_first); jbuttonfirst.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { currpagenum = 1 ; string[][] result = ((studentdao) basedao.getabilitydao(dao.studentdao)).list(currpagenum); initjtable(jtable, result); currpagenumjlabel.settext(appconstants.mainview_pagenum_jlabel_di + currpagenum + appconstants.mainview_pagenum_jlabel_ye); } }); jbuttonpre = new jbutton(appconstants.mainview_pre); jbuttonpre.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { currpagenum--; if (currpagenum <= 0 ) { currpagenum = 1 ; } string[][] result = ((studentdao) basedao.getabilitydao(dao.studentdao)).list(currpagenum); initjtable(jtable, result); currpagenumjlabel.settext(appconstants.mainview_pagenum_jlabel_di + currpagenum + appconstants.mainview_pagenum_jlabel_ye); } }); jbuttonnext = new jbutton(appconstants.mainview_next); jbuttonnext.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { currpagenum++; if (currpagenum > maxpagenum) { currpagenum = maxpagenum; } string[][] result = ((studentdao) basedao.getabilitydao(dao.studentdao)).list(currpagenum); initjtable(jtable, result); currpagenumjlabel.settext(appconstants.mainview_pagenum_jlabel_di + currpagenum + appconstants.mainview_pagenum_jlabel_ye); } }); jbuttonlast = new jbutton(appconstants.mainview_last); jbuttonlast.addactionlistener( new actionlistener() { @override public void actionperformed(actionevent e) { currpagenum = maxpagenum; string[][] result = ((studentdao) basedao.getabilitydao(dao.studentdao)).list(currpagenum); initjtable(jtable, result); currpagenumjlabel.settext(appconstants.mainview_pagenum_jlabel_di + currpagenum + appconstants.mainview_pagenum_jlabel_ye); } }); currpagenumjlabel = new jlabel( appconstants.mainview_pagenum_jlabel_di + currpagenum + appconstants.mainview_pagenum_jlabel_ye); currpagenumjlabel.sethorizontalalignment(jlabel.center); jpanelsouth.add(jbuttonfirst); jpanelsouth.add(jbuttonpre); jpanelsouth.add(currpagenumjlabel); jpanelsouth.add(jbuttonnext); jpanelsouth.add(jbuttonlast); this .add(jpanelnorth, borderlayout.north); this .add(jpanelcenter, borderlayout.center); this .add(jpanelsouth, borderlayout.south); setbounds( 400 , 200 , 750 , 340 ); setresizable( false ); setdefaultcloseoperation(dispose_on_close); setvisible( true ); } public static void initjtable(jtable jtable, string[][] result) { ((defaulttablemodel) jtable.getmodel()).setdatavector(result, column); jtable.setrowheight( 20 ); tablecolumn firsetcolumn = jtable.getcolumnmodel().getcolumn( 0 ); firsetcolumn.setpreferredwidth( 30 ); firsetcolumn.setmaxwidth( 30 ); firsetcolumn.setminwidth( 30 ); tablecolumn secondcolumn = jtable.getcolumnmodel().getcolumn( 1 ); secondcolumn.setpreferredwidth( 60 ); secondcolumn.setmaxwidth( 60 ); secondcolumn.setminwidth( 60 ); tablecolumn thirdcolumn = jtable.getcolumnmodel().getcolumn( 2 ); thirdcolumn.setpreferredwidth( 90 ); thirdcolumn.setmaxwidth( 90 ); thirdcolumn.setminwidth( 90 ); tablecolumn fourthcolumn = jtable.getcolumnmodel().getcolumn( 3 ); fourthcolumn.setpreferredwidth( 30 ); fourthcolumn.setmaxwidth( 30 ); fourthcolumn.setminwidth( 30 ); tablecolumn seventhcolumn = jtable.getcolumnmodel().getcolumn( 6 ); seventhcolumn.setpreferredwidth( 30 ); seventhcolumn.setmaxwidth( 30 ); seventhcolumn.setminwidth( 30 ); tablecolumn ninthcolumn = jtable.getcolumnmodel().getcolumn( 8 ); ninthcolumn.setpreferredwidth( 90 ); ninthcolumn.setmaxwidth( 90 ); ninthcolumn.setminwidth( 90 ); } private class findlistener extends keyadapter { @override public void keypressed(keyevent e) { if (e.getkeycode() == keyevent.vk_enter) { find(); } } } private void find() { currpagenum = 0 ; string param = condition.gettext(); if ( "" .equals(param) || param == null ) { initjtable(mainview.jtable, null ); currpagenumjlabel.settext(appconstants.mainview_find_jlabel); return ; } string[][] result = ((studentdao) basedao.getabilitydao(dao.studentdao)).querybyname(param); condition.settext( "" ); initjtable(mainview.jtable, result); currpagenumjlabel.settext(appconstants.mainview_find_jlabel); } } |
end.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:http://blog.csdn.net/ZhuangM_888/article/details/50476423