I'm working on a program that parses a text and prints the output like this
LS 1 -> 3
LS 2 -> 3
LS 3 -> 2
PRP itself -> 2
PRP it -> 5
DT all -> 7
DT All -> 11
DT no -> 9
DT a -> 77
NNP Milwaukee -> 2
NNP D65 -> 1
NNP STD -> 1
NNP Gimp -> 3
NNP Constitution -> 1
Instead i want something like
I Tried using JTable for 3 hours and couldn't still figure out how do i sort the text to table. Please Help.
Sample Code
public String getTagsList() throws IOException {
String output = "";
for (Map.Entry<String, Map<String, Integer>> entry : tagMap.entrySet()) {
String oa = entry.getKey();
Map<String, Integer> words = entry.getValue();
for (Map.Entry<String, Integer> entryWords : words.entrySet()) {
String ob = entryWords.getKey() + " -> " + entryWords.getValue();
output += oa + "\t" + ob + "\n";
}
}
return output;
}
And
try {
if (cmd == cmdOpen) {
int code = chooser.showOpenDialog(myPane);
if (code == JFileChooser.APPROVE_OPTION) {
File selectedFile = chooser.getSelectedFile();
fileName = selectedFile.getName();
TagText tagText = new TagText(selectedFile.getAbsolutePath(), 4);
myPane.setText(tagText.getTagsList());
}
}
}