-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowTable.java
More file actions
48 lines (39 loc) · 1.17 KB
/
ShowTable.java
File metadata and controls
48 lines (39 loc) · 1.17 KB
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
package workshop;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
public class ShowTable extends AbstractTableModel {
private String[] columnNames = {"ID", "PWD"};
private ArrayList<ToTable> datas;
public ShowTable(String strEname ) throws ClassNotFoundException, SQLException {
Database dao = new Database();
datas = dao.searchEname( strEname );
}
public String getColumnName(int column) {
return columnNames[column];
}
@Override
public int getRowCount() {
// TODO Auto-generated method stub
return datas.size();
}
@Override
public int getColumnCount() {
// TODO Auto-generated method stub
return 2;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
String result = "";
ToTable to = datas.get(rowIndex);
switch( columnIndex ) {
case 0:
result = to.getId();
break;
case 1:
result = to.getPwd();
break;
}
return result;
}
}