doha786 0 Light Poster

hi,

I am trying to build a small program that can search java ‘class’ files and ‘method’s from a repository where millions of java files are stored. In addition it has an algorithm(LONGEST COMMON SUBSEQUENCE) to compare the results to find the similarity percentage and user can make precision by putting threshold value before start searching.

I already done for java ‘class’ files and it can show results correctly in TextArea of GUI. But actually I want to show these results in JTable instead of textArea where result will create rows automatically in Table.

I am trying like this, has no error but no output..

Would anybody please check and help me......

public void actionPerformed(ActionEvent e) {
if(e.getSource()==searchButton){

FileReader reader;         String result="";             
String word= new String(); 
String target = "class";
 Map<String, File> names = new HashMap<String, File>();
 
try{ 

File directory = new File("C:/Java/Repository");// setting the repository path

File filelist[]= directory.listFiles();

      for (File f: filelist) {
   
reader = new FileReader (f);     
Scanner scan = new Scanner(reader); 

while(scan.hasNext()){ scan.next();
 result = scan.findWithinHorizon(target,0); 

if(result!=null) {
word = (scan.next() + scan.findWithinHorizon("", 0));
names.put(word,f); }

for (String found: names.keySet()){ } 

   }
  }
   }
         String SearchClass=txtField.getText();
              
         for (String found: names.keySet()) {
         DecimalFormat myformat=new DecimalFormat("###.##");
         double compare = MyGui.LCS(found, SearchClass);
         double getThreshold = Double.parseDouble(threshold.getText());
      
      
         if (compare >= getThreshold) {
               File file = names.get(found);

      //previously show resutls in textArea correctly
               //txtArea.append(found+"\t\t\t\t"+myformat.format(compare) +" \t\t\t "+ file.getName()+"\n");  
          

//now i want to make column and row to show that same results     
            try {  
               DefaultTableModel model= new DefaultTableModel();
Vector<String> vCol = new Vector<String>();
 vCol.addElement("NAMES");    vCol.addElement("SIMILAIRY");    vCol.addElement("FILE PATH"); 

          Vector<String> row;
        Vector<Vector> vRow=new Vector<Vector>();        
         
         row= new Vector<String>();
                        
 row.addElement(found); row.addElement(myformat.format(compare)); row.addElement(file.getName());
//  row.addElement(""+found); row.addElement(""+myformat.format(compare)); row.addElement(""+file.getName());
      
         vRow.addElement(row);
        model.addRow(vRow);
        model = new DefaultTableModel(vRow, vCol); 
   
JTable table = new JTable(model);
      
JScrollPane scrollpane = new JScrollPane(table);
resultSet.add(scrollpane);
        }
       catch(Exception exc)
                  {
                     System.out.println("Error!" + exc);
                  }

            }