Results 1 to 5 of 5
- 02-05-2010, 02:58 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 48
- Rep Power
- 0
How to solve this JTable problem?? [REPOST]
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 SUBSEQUENT) 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......
Java Code: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); }Last edited by doha786; 02-05-2010 at 03:47 AM.
- 02-05-2010, 03:03 AM #2
Member
- Join Date
- Mar 2009
- Posts
- 48
- Rep Power
- 0
oppss..same problem happened.
why the code tags is not working here ? is it because of the code is too big ??
- 02-05-2010, 03:26 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
why the code tags is not working here ? is it because of the code is too big ?
Try using spaces to indent rather than tabs. Spaces act more predictably when displayed as part of a web page. You might also want to avoid very long lines - code is easier to read in any context when it consists of moderate length lines.
- 02-05-2010, 03:31 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
What's resultSet?
Post a small example that shows how you are trying to display the data. Something that actually compiles. It does not have to include the searching/formatting/tolerance stuff as this has nothing to do with your problem.
- 02-05-2010, 04:02 AM #5
Member
- Join Date
- Mar 2009
- Posts
- 48
- Rep Power
- 0
resultSet is a Panel where i want to set this JTable.
JTable has three columns - "NAMES" "SIMILARITY" AND "FILE PATH"
so found search results will come under this and make rows which has value of "class name", "similarity percentage like..40%,50% " and "show location of that file"
if 20 result found..20 rows will create in JTable..
thats all... thanks
Similar Threads
-
How to solve this JTable problem??
By doha786 in forum New To JavaReplies: 5Last Post: 02-05-2010, 02:45 AM -
Could someone help me to solve this problem...
By Vinny in forum Java SoftwareReplies: 1Last Post: 07-08-2009, 06:59 PM -
Help me to solve problem
By mansoorhacker in forum Forum GuidesReplies: 8Last Post: 01-24-2009, 06:29 PM -
Help me to solve problem
By mansoorhacker in forum New To JavaReplies: 3Last Post: 11-13-2008, 08:15 AM -
Jtable duplicates through Hashtable (JTable condition problem) my assignment plz help
By salmanpirzada1 in forum Advanced JavaReplies: 2Last Post: 05-15-2008, 10:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks