Search code examples
javaswingjtablejscrollpanecheckbox

Ho do I display results from a db query in a scroll pane with an array of checkboxes?


In java I query a db and retrieve a result set, which I want to display in a scrolling pane.

Along with displaying the the results of the query, I want to have a checkbox on the left side of each row in the scrolling pane.

Adding the checkboxes is the part that I don't know how to do. Any suggestions on how to do this would be greatly appreciated.

I am using Swing and my IDE is Netbeans 7.1.


Solution

  • In addition to @Stan's example, the default renderer and editor for Boolean is a JCheckbox, so return Boolean for the column's class. There's an example here.