-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKeyWordTableModel.java
67 lines (50 loc) · 1.23 KB
/
KeyWordTableModel.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
package com.smartsystem.keywordsearch.ui;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import com.smartsystem.keywordsearch.core.KeyWord;
public class KeyWordTableModel extends AbstractTableModel {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final int KEYWORD_COL = 0;
private static final int POSTS_COL = 1;
private String[] colunmNames = {"KeyWord", "Posts"};
private List<KeyWord> wordKey;
public KeyWordTableModel(List<KeyWord> theKeyWord){
wordKey = theKeyWord;
}
@Override
public int getColumnCount() {
return colunmNames.length;
}
@Override
public int getRowCount() {
return wordKey.size();
}
public String getColunmName(int col) {
return colunmNames[col];
}
@Override
public Object getValueAt(int row, int col) {
KeyWord tempKeyWord = wordKey.get(row);
switch(col){
case KEYWORD_COL:
return tempKeyWord.getKeyword();
case POSTS_COL:
return tempKeyWord.getPosts();
default:
return tempKeyWord.getKeyword();
}
}
public static int getKeywordCol() {
return KEYWORD_COL;
}
public static int getPostsCol() {
return POSTS_COL;
}
@Override
public Class getColumnClass(int c){
return getValueAt(0, c).getClass();
}
}