SwingBuilder - doing an editable checkbox in a column of a table

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

SwingBuilder - doing an editable checkbox in a column of a table

mecorusfc
I've been able to get a checkbox rendered in a table and it shows the correct values from the model based on my renderer and display strategy.  My problem is that I can't figure out how to make it so I can actually click the checkbox in the table and have it generate some kind of event I can trap and do something with.  I've tried listeners and editors and nothing seems to work for me.  I'm sure I'm doing something fundamentally wrong but I can't find an example for my situation.  Note that I don't have actual JCheckBox objects (there's nowhere to define that in a default advanced table format).  Here's some code that at least gets me to read-only checkboxes that display the correct data:

table(id: 'tradingProgramTable', name: 'tradingProgramTable') {
         tableFormat = defaultAdvancedTableFormat(columns: defineTableFormatOnLeft())
         eventTableModel(source: model.tradingPrograms, format: tableFormat)
}
tradingProgramTable.columnModel.getColumn(6).setCellRenderer(new CheckBoxRenderer())

My definteTableFormatOnLeft() method returns an array of the names, classes and readers (all the same) and that seems to be working fine.  Note that I also have a mouse listener over the whole table looking for a double-click on any row which fires off another dialog in a window for that row.  That's all working fine and I don't think it would get in the way.

What types of classes would I need to use and how would I wire them up in the DSL to get writable checkboxes that fire an event when I click them?  I'm fine to do research if somebody can send me in the right direction.  I'm having trouble relating all this to how I do it inside the builder with the DSL.
Reply | Threaded
Open this post in threaded view
|

Re: SwingBuilder - doing an editable checkbox in a column of a table

mecorusfc
Ignore.  I figured out that the mouse listener was swallowing up all the events.  I just put my code in the mouse listener and it worked.