Load JList for cells of 1st column in JTable - java

Is there any way to load JList on the first column of JTable on click?
The table has zones in the 1st column (with multiple locations in every zone). I want to show zone locations to the user in a list, on zone click.
I am looking for it from 1 and half day. I don't want to put my code here because there is a lot of functionality in my table class.

One approach would be to add a ListSelectionListener to the table, as shown here, and update your ListModel according to the row selected. A JList listens to its own ListModel, so the update should be automatic.

Related

How can I render a JList inside a JTable cell?

In three of the columns of my JTable that I have set up I would like to have a list in each cell of the column. I'm not sure where to start on possibly creating a custom cell renderer class if that's the best option? My goal is to list the group names each on their own line in each cell, and expand the cell height as new lines are added. Each group will have an AdmType and Admitted entry, so I will also need to figure out how to add another checkbox to the Admitted column cell for every new Group entry.
This below solution did not work for me, but it clearly worked for the person who posted a screen shot of their success. My problems may be due to how I have my TableModel set up.
https://stackoverflow.com/a/32793088/6867420

JCalendar multiple day selection

Is it possible to select multiple days in toedter's JCalendar? Like I would be able to highlight 2 or 3 days in the calendar and then get the days highlighted after I would trigger an event using a button.
or should i be better off using a JTable for a calendar?
I'd use a one column JTable having a JDateChooserCellEditor and a custom renderer. DemoTable is an example, seen here. The TableModel should contain a List<java.util.Date>, as Date implements Comparable for easy sorting. You can supply an addRow() method in DemoTableModel, which can be invoked in your Add button's handler.

How to restrain checking single checkbox in multiple columns in Jtable

I am trying to implement a Jtable which includes three check-box tables like this:
Can you tell me how to set a single selection group of checkboxes which only allows 1 selected check-box in a single row at any time?
I know of nothing out-of-the-box for doing this. I´d have a TableModelListener check these columns every time a change is made and call setValueAt on the checkboxes as needed.

JTable multiple instances

I have a JTable that gets data added to it from another JTable.
Now I want to switch between JTables according to the day selected in a JComboBox.
For example, if I choose Monday I add programs added to it then I select Tuesday from the JComboBox and a fresh JTable appears. If I go to Monday again the programs should still be there (until the program is closed).
How do I create multiple JTables (the JTable remains the same) for the days and let the info remain there until program closure?
Here is an example to show you what I mean:
Filtering the rows in an existing table seems easier. See Sorting and Filtering for how to create a RowFilter, instances of which can be added to a JComboBox and applied in the combo's action listener.

adding JComboBox to a jTable with specific data per row

I am trying to add a JComboBox to the last column of my JTable. The JComboBox isn't for editing purposes but for traversing the JTable itself. Each row can have 0-many elements that need to go in the JComboBox and when a value is selected from the box I need to scroll to a different row in the JTable.
All the research I have done points me specifically to editors and renderers with the down fall being that data in the JComboBox is set per column so that a user can select a value for the cell in the row. Where as I need values that are specific to the row.
So my question is, has anyone tried to do this before? and Can you point me to some good information on how to do this? or even better could you describe how you did this?
1/ simple example here, your job is only to move (hold) TableCellEditor to the last row in the TableView,
2/ if JComboBox's Item changed then search in TableModel for TableRow (if every TableColumns ends with JComboBox)
3/ then call myTable.changeSelection(row, column, false, false);
4/ possible fauls implemented and used RowSorter, RowFilter, then you have to get int row from TableView and convert that to the TableModel by using
int modelRow = convertRowIndexToModel(row);

Categories