views:

432

answers:

1

following this tutorial http://www.netbeans.org/kb/docs/java/gui-db-custom.html#enhancements

it shows how to use a textbox to filter out the master table. Could anyone instruct me on how to do a similiar thing but use a dropdown to test against a specific column?

(ie a dropdown of countries, to filter by the country column?

thanks

A: 

depending on what the source is for the dropdown. i assume the dropdown isn't used as part of the Jtable itself, but merely shows a list of unique data coming from one column of data? in that case, you could get the Jtable's datamodel, and then walk through all the cells in the particular column, putting them in a hashmap with the string as the key. that way you have a list of (unfiltered) unique strings to use as the datamodel for the dropdownbox. You could attach a model listener to the talbedatamodel to know when your list has to be updated as well.

Houtman