java - unable to do consecutive search -
public boolean searchsummarydata(string texttofind) { int fromrow, fromcol; fromrow = summarytable.getselectedrow(); fromcol = summarytable.getselectedcolumn(); if (fromrow < 0) { fromrow = 0; //set start point, first row } if (fromcol < 0) { fromcol = 0; } else { fromcol++;//incremental search - through each columns, switch next row if (fromcol >= summarytable.getcolumncount()) { fromcol = 0; fromrow++; } } (int = fromrow; < summarytablemodel.getrowcount(); i++) { (int j = fromcol; j < summarytablemodel.getcolumncount(); j++) { final object valueat = summarytablemodel.getvalueat(i, j); //point object @ i,j if (valueat != null) { texttofind = texttofind.tolowercase(); if (valueat.tostring().tolowercase().contains(texttofind)) { //map index of column/row in table model @ j/i index of column/row in view. int convertrowindextoview = summarytable.convertrowindextoview(i); int convertcolindextoview = summarytable.convertcolumnindextoview(j); summarytable.setrowselectioninterval(i, i); summarytable.setcolumnselectioninterval(j, j); //return rectangle cell lies @ intersection of row , column. rectangle recttoscrollto = summarytable.getcellrect(convertrowindextoview, convertcolindextoview, true); tablesp.getviewport().scrollrecttovisible(recttoscrollto); homecoming true; } } } } homecoming false; }
i having problem search method above. way did it, allows me search particular matched keyword once. while beingness in same guiscreen, if sec search, if keyword matched, no result found. pretty sure lastly searched index kept , not reset problem, im unsure , how alter this.
you setting fromrow
, fromcol
vars selected row , column. , changing selection first result found. if sec search have found things left or above current selection, won't find anything.
why don't set fromrow
, fromcol
0, 0 in first place?
java swing for-loop jtable abstracttablemodel
No comments:
Post a Comment