I want to have a feature with JTable wherein I'll provide a textfield to enter a value to be searched from the JTable and if this entered value matches with any of the cell values in the JTable then that particular cell should be highlighted & the cell font should be turned to BOLD. The values will be matched when the user presses Enter key after specifying the value in the text field.
Now I am able to search a value from the JTable, & on a successful search I call the TableCellRenderer. But the thing is on a successful search I try & edit that particular cell so that it is selected. But the method editCellAt(row, column) returns a false. And also how do I give a focus on that particular matched cell. Due to this even if the cell renderer runs it reflects me no change in the JTable cell.
Can anyone plz help me out with this problem. It is very urgent. All help is appreciated.
Heyy thanx for the code. But when I tried implementing this code, it blanked out all the cells of the JTable. Could you let me know some other solution for the problem.
Just add this line to your table and to an actionListener.
JTable myJTable;
myJTable.getSearchable(); //This line implements pops up a search box when you add this line to an actionlistener for (ctrl+f). getSearchable() is a default search function for JTable. it provides, case sensitive/forward/backward search
Sandesh Shankarappa wrote:Just add this line to your table and to an actionListener.
JTable myJTable;
myJTable.getSearchable(); //This line implements pops up a search box when you add this line to an actionlistener for (ctrl+f). getSearchable() is a default search function for JTable. it provides, case sensitive/forward/backward search
Did you invent that or are you referring to some third party JTable class unfortunately named the same as the one in the standard JDK, javax.swing.JTable?
JTable doesn't have a getSearchable() method. Note: method, not function. Java doesn't have functions.
And welcome to the Ranch!
luck, db
There are no new questions, but there may be new answers.
Sandesh Gowda
Greenhorn
Joined: Jun 04, 2012
Posts: 4
posted
0
I did not invent it, the function is part of searchable class under swing.
The following line of code pops up a find window with forward/backward/case sensitive search options.
SearchFactory.getInstance().showFindInput(myjTable, myjTable.getSearchable());
I am working on incremental search in jtable and I came across this question, I thought it would help someone like me who is working on searchables in jtable Do you know how to make getSearchable to forward search from selected row instead of searching from the first row of the table?