KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SnowMailClient > SpamFilter > StatViewer


1 package SnowMailClient.SpamFilter;
2
3 import snow.sortabletable.*;
4 import snow.utils.gui.*;
5 import javax.swing.*;
6 import javax.swing.event.*;
7 import java.awt.*;
8 import java.awt.event.*;
9 import SnowMailClient.Language.*;
10 import SnowMailClient.*;
11 import java.util.*;
12
13 public final class StatViewer extends JDialog
14 {
15   final private JTable table = new JTable();
16   final private SortableTableModel sortableTableModel;
17   final private Map<String JavaDoc,Word> wordsTable = SnowMailClientApp.getInstance().getWordStatistic().getAllWords();
18
19   public final static String JavaDoc TITLE = Language.translate("SPAM Statistics");
20
21   public StatViewer(JFrame parent)
22   {
23     super(parent, TITLE, true);
24     getContentPane().setLayout(new BorderLayout());
25
26     // Center
27

28     sortableTableModel = new SortableTableModel(new SpamStatTableModel(wordsTable));
29     table.setModel(sortableTableModel);
30     sortableTableModel.installGUI(table);
31     this.getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
32
33     // Search
34
AdvancedSearchPanel searchPanel = new AdvancedSearchPanel(Language.translate("Search")+": ", null, sortableTableModel, true);
35     this.getContentPane().add(searchPanel, BorderLayout.NORTH);
36
37     // Close Panel
38
CloseControlPanel ccp = new CloseControlPanel(this, false, true, Language.translate("Close"));
39     this.getContentPane().add(ccp, BorderLayout.SOUTH);
40
41     updateTitleLabel();
42
43     SnowMailClientApp.getInstance().getProperties().setComponentSizeFromINIFile(
44       this, "SpamStatViewer", 340,600, 200,100);
45     setVisible(true);
46     SnowMailClientApp.getInstance().getProperties().saveComponentSizeInINIFile(this, "SpamStatViewer");
47   } // Constructor
48

49
50   private void updateTitleLabel()
51   {
52     String JavaDoc hitString = (sortableTableModel.getRowCount()<wordsTable.size() ?
53          " ("+sortableTableModel.getRowCount()+" "+Language.translate("hits")+")"
54         :"");
55     setTitle(TITLE+" ["+wordsTable.size()+" "+Language.translate("words")+"]"+hitString);
56   }
57
58
59 } // StatViewer
Popular Tags