问题
i have a JTable and JLabel , i have put some values in the Table ! i want to implement search in that table and then set the value from the searched value on the JLabel.
suppose i type 'f' so myfunction will search where in myTable's row and 0th column the value starts with f , thus i ll get that row value ! now i want to select/highlight that entire row and print the value on JLabel.
I don't know how to highlight this row! is there any better method to do searching , i have read about SwingX , but i did not find how to actually use JXTables.
回答1:
Maybe it would be better for you to use the filtering
capabilities of JTable.
The Swing tutorial on Sorting and Filtering give a working example on how this can be done to filter all the rows that start with the text entered in your text field.
I don't understand your question about updating a "label", since it is possible that multiple rows could start with the search string.
来源:https://stackoverflow.com/questions/24084922/how-to-select-a-complete-row-on-pressing-a-key-and-then-search-the-element-store