I am using Glazedlists
with yaml
. In glazedlists
they are providing textfilterator
for filtering the jtable
.
Now I want to filter the table based on the jcombobox values .So am try to use jcombobox
as my filter.I try with the textfilterator
. But its not working. I am not clear about the matcher. So if anyone know is there any filterator
for jcombobox
.
My code snippet is given below :
JPanel(name=ProductPanel,preferredSize=660x400,maximumSize=650x400,minimumSize=650x400): - JPanel(name=insideProductPanel,preferredSize=660x400,maximumSize=660x400,minimumSize=660x400): - JComboBox(name=cmbSearchCategory,onAction=searchCategory): EventComboBoxModel(source=searchComboList): - JTextField(name=txtSearchProduct): - JScrollPane(name=productScroll,vScrollBar=never,preferredSize=650x400,maximumSize=650x400,minimumSize=650x400): JTable(name=productTable): - EventTableModel(name=productModel,source=productList): - TextFilterator(txtSearchProduct=[name]) - TableColumn(name=id,headerValue="#",preferredWidth=300): - TableColumn(name=productCode,headerValue="code"): - TableColumn(name=name,headerValue="Product"): - TableColumn(name=category,headerValue="Category"): - TableColumn(name=unit,headerValue="UOM"): - TableColumn(name=batchEnabled,headerValue="Batch"): - TableColumn(name=type,headerValue="Type of Product"):
- MigLayout: |
[grow]
Firstly, your example code makes no sense. It doesn't have any semblance of actual Java code and doesn't in any way abide by the SSCCE principle.
That said, your question provides enough clues to ascertain your requirements. GlazedLists does provide a framework for dynamically filtering lists and it's all done via the
MatcherEditor
class.There are some great screencasts available at GlazedLists Developer and there's a simple example dealing with precisely the task you raise about how to link up a MatcherEditor with the JComboBox selection in order to trigger dynamic filtering.
The source for this example is short enough to include here:
You will need to build your own MatcherEditor for your particular needs, but the example above provides a good template. It's the aim of the MatcherEditor to provide the logic to decide what is filtered out, or technically speaking what stays in for a particular input.
Your MatcherEditor also needs to have some sort of access to the component you wish to trigger the filtering. Many examples have the MatcherEditor as been the creator and owner of the particular Swing component, but it's equally fine to have it passed in.
And then it's just a case of hooking up the MatcherEditor to a FilterList, which you'll be familiar with if you've done text filtering.