I currently have a table with a textfield in the individual column headers that does filtering based on each of their individual columns.. I am trying to use glazed list instead but how do I do it? each column should have an individual textfield and filtering is done based on all the textfields which filters based on individual columns. E.G: Table with column "First name" and "Last name". The table will filter results based on person with first name based in the firstname filter and with last names based on the last name filter
Java GlazedList individual column filtering
240 Views Asked by Cherple At
1
There are 1 best solutions below
Related Questions in JAVA
- I need the BIRT.war that is compatible with Java 17 and Tomcat 10
- Creating global Class holder
- No method found for class java.lang.String in Kafka
- Issue edit a jtable with a pictures
- getting error when trying to launch kotlin jar file that use supabase "java.lang.NoClassDefFoundError"
- Does the && (logical AND) operator have a higher precedence than || (logical OR) operator in Java?
- Mixed color rendering in a JTable
- HTTPS configuration in Spring Boot, server returning timeout
- How to use Layout to create textfields which dont increase in size?
- Function for making the code wait in javafx
- How to create beans of the same class for multiple template parameters in Spring
- How could you print a specific String from an array with the values of an array from a double array on the same line, using iteration to print all?
- org.telegram.telegrambots.meta.exceptions.TelegramApiException: Bot token and username can't be empty
- Accessing Secret Variables in Classic Pipelines through Java app in Azure DevOps
- Postgres && statement Error in Mybatis Mapper?
Related Questions in FILTERING
- Filtering a double value
- How the search filter from search bar works in mern?
- How to represent a filter in JSON?
- Functions to filter missing values in SQL and change them to null values
- Namely Api filter for field NOT Equal
- Blazor Radzen filtering and sorting not working/interacting
- How to filter values from showing up in a Looker Studio Time Series Chart
- Change filter binding mode in Blazor Bootstrap Grid (https://demos.blazorbootstrap.com/grid)
- Is there any way to remove log.syslog.structured_data field in logscale/kibana
- Filter data table based on a search term with variations
- Clarification on the concept of using a separable filter vs. without a separable filter
- Display only the current user logged in records in the index view in ASP.NET Core MVC?
- jqxGrid not able to cutomize derived column filters using "addfilter" function
- Filtering algorithm working on one machine but not on other
- Filtering Angular 17
Related Questions in GLAZEDLISTS
- How to filter multi-line text?
- How are values compared in NatTable with GlazedLists?
- Sorting in NatTables
- How to disable autocomplete but keep autosuggestion using GlazedLists?
- How to sort a TreeList with a different comparator for each column in a NatTable
- GlazedList: using the set method to update eventlist displayed in table removes table selection
- GlazedList sorted list sort order based on table's comparatorProperty
- Java GlazedList individual column filtering
- How to pass the same ListEventPublisher and ReadWriteLock to CollectionList and child EventLists in GlazedLists?
- NatTable: Table don't react on filtering
- Sorting of tree implemented with NatTable
- GlazedList update EventList in JTable
- Delete multiple columns in NatTable
- How to observe changes in glazedlists in griffon?
- How to prevent selection of SeparatorList.Separator in a JList?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The first thing you need to get your head around is that GlazedLists is primarily about handling lists of objects -- the clue is in the name. Many people approach it as a library for adding sorting & filtering capabilities to tables and lists, which is guaranteed to cause headaches.
So focus first on the fact that GlazedLists will provide you with a special type of list structure called an
EventList, which is your core data structure; from there you will be provided with useful methods for transforming, sorting, filtering etc. And then, because it's super-generous, there are easy to use classes to link up your EventList to a JList or JTable.Once this is all wired up, changes and transformations to the list will automatically propagate to any Swing components which are linked to it.
Anyway, here's a sample class which will show you how you create an EventList, then to apply text filters via a Swing component, and then to link it all up to a Swing table. (This doesn't cover sorting, or how to obtain selected items, but the docs are excellent.)
Tested with Java 9 and GlazedLists 1.11.
import ca.odell.glazedlists.*; import ca.odell.glazedlists.gui.TableFormat; import ca.odell.glazedlists.matchers.MatcherEditor; import ca.odell.glazedlists.swing.DefaultEventSelectionModel; import ca.odell.glazedlists.swing.DefaultEventTableModel; import ca.odell.glazedlists.swing.TextComponentMatcherEditor; import javax.swing.*; import java.awt.*; import java.util.List; public class GlazedListsMultipleTextfields { private JFrame frame; private JTable table; private JTextField txtFirstName; private JTextField txtLastName; private EventList people; private DefaultEventSelectionModel selectionModel; public GlazedListsMultipleTextfields() { setupGui(); setupGlazedLists(); populatedList(); frame.setVisible(true); } private void setupGui() { frame = new JFrame("GlazedLists Multiple Filter Examples"); frame.setSize(600, 600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create the panel to hold the input textfields txtFirstName = new JTextField(); JPanel pnlFirstName = new JPanel(new BorderLayout()); pnlFirstName.add(new JLabel("First name"), BorderLayout.WEST); pnlFirstName.add(txtFirstName, BorderLayout.CENTER); txtLastName = new JTextField(); JPanel pnlLastName = new JPanel(new BorderLayout()); pnlLastName.add(new JLabel("Last name"), BorderLayout.WEST); pnlLastName.add(txtLastName, BorderLayout.CENTER); JPanel textInputs = new JPanel(); textInputs.setLayout(new BoxLayout(textInputs, BoxLayout.Y_AXIS)); textInputs.add(pnlFirstName); textInputs.add(pnlLastName); table = new JTable(); frame.getContentPane().add(new JScrollPane(table), BorderLayout.CENTER); frame.getContentPane().add(textInputs, BorderLayout.NORTH); } private void populatedList() { people.add(new Person("John", "Grisham")); people.add(new Person("Patricia", "Cornwell")); people.add(new Person("Nicholas", "Sparks")); people.add(new Person("Andy", "Weir")); people.add(new Person("Elizabeth", "George")); people.add(new Person("John", "Green")); } private void setupGlazedLists() { people = new BasicEventList(); MatcherEditor firstNameMatcherEditor = new TextComponentMatcherEditor(txtFirstName, new FirstNameTextFilterator()); MatcherEditor lastNameMatcherEditor = new TextComponentMatcherEditor(txtLastName, new LastNameTextFilterator()); FilterList filteredFirstNames = new FilterList(people, firstNameMatcherEditor); FilterList filteredLastNames = new FilterList(filteredFirstNames, lastNameMatcherEditor); TableFormat tableFormat = GlazedLists.tableFormat(new String[]{"firstName", "lastName"}, new String[]{"First Name", "Last Name"}); DefaultEventTableModel model = new DefaultEventTableModel(filteredLastNames, tableFormat); selectionModel = new DefaultEventSelectionModel(filteredLastNames); table.setModel(model); table.setSelectionModel(selectionModel); } class FirstNameTextFilterator implements TextFilterator { @Override public void getFilterStrings(List list, Person person) { list.add(person.getFirstName()); } } class LastNameTextFilterator implements TextFilterator { @Override public void getFilterStrings(List list, Person person) { list.add(person.getLastName()); } } public class Person { private String firstName; private String lastName; public Person(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new GlazedListsMultipleTextfields(); } }); } }