Example usage for javax.swing.table DefaultTableModel DefaultTableModel

List of usage examples for javax.swing.table DefaultTableModel DefaultTableModel

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableModel DefaultTableModel.

Prototype

public DefaultTableModel(Object[][] data, Object[] columnNames) 

Source Link

Document

Constructs a DefaultTableModel and initializes the table by passing data and columnNames to the setDataVector method.

Usage

From source file:vn.hieptn.interesttopic.InterestTopicMain.java

private void cmboxTopicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmboxTopicActionPerformed
    // TODO add your handling code here:
    if (cmboxTopic != null && cmboxTopic.getSelectedItem() != null) {
        String selectedName = cmboxTopic.getSelectedItem().toString();
        ClassifiedTopicEnt tmpTopicEnt = ConfigInfo.MAP_TOPIC_REPORT.get(selectedName);
        if (tmpTopicEnt != null) {
            Vector<Vector<String>> dataMessage = new Vector<Vector<String>>();
            String[] listKeyword = StringUtils.split(tmpTopicEnt.Keyword, "#");
            if (listKeyword != null && listKeyword.length > 0) {
                for (String tmpKeyword : listKeyword) {
                    if (!tmpKeyword.isEmpty()) {
                        String[] listWord = StringUtils.split(tmpKeyword, "|");
                        Vector<String> vstring = new Vector<String>();
                        vstring.add(listWord[0]);
                        vstring.add(listWord[1]);
                        vstring.add("\n\n\n\n\n\n\n");
                        dataMessage.add(vstring);
                    }//  www  . j  ava 2s .c  o m
                }
            }
            Vector<String> columnNamesMessage = new Vector<String>();
            columnNamesMessage.add("Word");
            columnNamesMessage.add("Probability");
            tableKeyword.setModel(new DefaultTableModel(dataMessage, columnNamesMessage));
            jScrollPane4.setViewportView(tableKeyword);
            tableKeyword.setVisible(true);
        }
    }

    //Get Post of Topic
    Vector<Vector<String>> dataMessage = DataBaseService.GetDataClassifiedMessage(1, 1);
    System.out.println("Check");
}

From source file:vn.hieptn.interesttopic.InterestTopicMain.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:

    List<MainTopicEnt> listMainTopic = DataBaseService.GetListMainTopicEnt();
    List<ClassifiedTopicEnt> lstTopic = DataBaseService.GetListDataClassifiedTopic();
    if (lstTopic != null && lstTopic.size() > 0 && listMainTopic != null && listMainTopic.size() > 0) {
        //Tinh So Vocalbulary
        int numVocabulary = 0;
        int numVocabularyWinDuplicate = 0;
        for (MainTopicEnt tmpMainTopicEnt : listMainTopic) {
            numVocabulary += tmpMainTopicEnt.NumKeywordNoDuplicate;
            numVocabularyWinDuplicate += tmpMainTopicEnt.NumKeyword;
        }/*from   ww w  .  j a va  2  s. c o m*/

        //Tinh Xac Suat Cho Tung TOPIC
        HashMap<String, Double> mapXSTopic = new HashMap<String, Double>();
        for (ClassifiedTopicEnt tmpTopicEnt : lstTopic) {
            List<String> listKeywordOfTopic = FunctionUtils.ConvertListKeywordOfTopic(tmpTopicEnt.Keyword);
            for (MainTopicEnt tmpMainTopicEnt : listMainTopic) {
                int numN = 0;
                HashMap<String, Integer> mapNK = new HashMap<String, Integer>();

                for (String tmpKeywordTopic : listKeywordOfTopic) {
                    int nShowTime = FunctionUtils.CountWordShow(tmpKeywordTopic, tmpMainTopicEnt.Message2);
                    numN += nShowTime;
                    String KeyMapKeywordTopic = tmpKeywordTopic + "|" + tmpMainTopicEnt.TopicName;
                    mapNK.put(KeyMapKeywordTopic, nShowTime);
                }

                //Tinh Xac Suat Cua Tung Key Word
                HashMap<String, Double> mapXSKeyword = new HashMap<String, Double>();
                for (String tmpKeywordTopic : listKeywordOfTopic) {
                    String KeyMapKeywordTopic = tmpKeywordTopic + "|" + tmpMainTopicEnt.TopicName;
                    int numNK = mapNK.get(KeyMapKeywordTopic) > 0 ? mapNK.get(KeyMapKeywordTopic) : 0;
                    double XSKeyword = ((double) (numNK + 1)) / ((double) (numN + numVocabulary));
                    mapXSKeyword.put(KeyMapKeywordTopic, XSKeyword);
                }

                //Xac Suat Cho Main Topic
                double pMainTopic = ((double) tmpMainTopicEnt.NumKeyword)
                        / ((double) numVocabularyWinDuplicate);

                //Xac Suat cho Topic voi Main Topic
                String KeyMapTopic = tmpTopicEnt.TopicName + "|" + tmpMainTopicEnt.TopicName;
                double pMainTopicSum = ProbabilityCalculation.LogBase2(pMainTopic);
                for (String tmpKeywordTopic : listKeywordOfTopic) {
                    String KeyMapKeywordTopic = tmpKeywordTopic + "|" + tmpMainTopicEnt.TopicName;
                    double XSKeyword = mapXSKeyword.get(KeyMapKeywordTopic);
                    pMainTopicSum += ProbabilityCalculation.LogBase2(XSKeyword);
                }
                mapXSTopic.put(KeyMapTopic, pMainTopicSum);
            }
        }

        //Tim Chu De Chinh Cho Tung TOPIC
        Vector<String> columnNamesMessage = new Vector<String>();
        columnNamesMessage.add("Chu De An");
        for (MainTopicEnt tmpMainTopicEnt : listMainTopic) {
            columnNamesMessage.add("XS " + tmpMainTopicEnt.TopicName);
        }
        columnNamesMessage.add("Chu De");

        Vector<Vector<String>> dataMessage = new Vector<Vector<String>>();
        for (ClassifiedTopicEnt tmpTopicEnt : lstTopic) {
            String topicNameFind = "";
            double XSTopic = 0;
            double XSTopicDuplicate = 0;
            boolean isWaiting = false;
            Vector<String> vstring = new Vector<String>();
            vstring.add(tmpTopicEnt.TopicName);

            for (MainTopicEnt tmpMainTopicEnt : listMainTopic) {
                String KeyMapTopic = tmpTopicEnt.TopicName + "|" + tmpMainTopicEnt.TopicName;
                double tmpXSTopic = mapXSTopic.get(KeyMapTopic);
                if (XSTopic == 0 || tmpXSTopic > XSTopic) {
                    XSTopic = tmpXSTopic;
                    topicNameFind = KeyMapTopic;
                }
                if (XSTopicDuplicate == 0 || tmpXSTopic == XSTopicDuplicate) {
                    XSTopicDuplicate = tmpXSTopic;
                    isWaiting = true;
                } else {
                    isWaiting = false;
                }
                vstring.add(String.format("%.6f", tmpXSTopic));
            }
            String[] listWord = StringUtils.split(topicNameFind, "|");
            if (isWaiting) {
                vstring.add("Dang Cho Phan Lop");
            } else {
                vstring.add(listWord[1]);
            }
            vstring.add("\n\n\n\n\n\n\n");
            dataMessage.add(vstring);
        }

        tableResultFindHideTopic.setModel(new DefaultTableModel(dataMessage, columnNamesMessage));
        jScrollPane8.setViewportView(tableResultFindHideTopic);
        tableResultFindHideTopic.setVisible(true);
    }
}

From source file:vn.hieptn.interesttopic.InterestTopicMain.java

private void cmbTrainTopicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbTrainTopicActionPerformed
    // TODO add your handling code here:
    if (cmbTrainTopic != null && cmbTrainTopic.getSelectedItem() != null) {
        String selectedName = cmbTrainTopic.getSelectedItem().toString();
        TrainTopicEnt tmpTopicEnt = ConfigInfo.MAP_TRAIN_TOPIC
                .get(selectedName + "|" + ConfigInfo.cmbMainTopicResult_ID);
        if (tmpTopicEnt != null) {
            Vector<Vector<String>> dataMessage = new Vector<Vector<String>>();
            String[] listKeyword = StringUtils.split(tmpTopicEnt.Keyword, "#");
            if (listKeyword != null && listKeyword.length > 0) {
                for (String tmpKeyword : listKeyword) {
                    if (!tmpKeyword.isEmpty()) {
                        String[] listWord = StringUtils.split(tmpKeyword, "|");
                        Vector<String> vstring = new Vector<String>();
                        vstring.add(listWord[0]);
                        vstring.add(listWord[1]);
                        vstring.add("\n\n\n\n\n\n\n");
                        dataMessage.add(vstring);
                    }//from   w w  w  . j a  v  a 2  s  . c om
                }
            }
            Vector<String> columnNamesMessage = new Vector<String>();
            columnNamesMessage.add("Word");
            columnNamesMessage.add("Probability");
            tableTrainTopicKeyword.setModel(new DefaultTableModel(dataMessage, columnNamesMessage));
            jScrollPane7.setViewportView(tableTrainTopicKeyword);
            tableTrainTopicKeyword.setVisible(true);
        }
    }
}