Adding CheckBox to DefaultTableModel

I have a DefaultTableModel which is populated with an Object[][] array.

Now I want to add a column with checkBoxes and perform operations accordingly.

When I add the checkbox into the Object[][] array and view it, I get text displayed

'javax.swing.JCheckBox[,0,0,0x0....', how do I get it to show a checkbox and add actions to it?

Answers


JTable have default checkbox renderer/editor for boolean values. Just make your TableModel#getColumnClass return Boolean.class for given column.


Need Your Help

How to fetch change from Git using LibGit2Sharp?

c# .net git version-control libgit2sharp

The code below clone a Git url to a test directory.

WinAPI LPWSTR, C++11 u16string?

c++ winapi unicode c++11

If I'm developing for Windows and some WinAPI functions require me to use LPWSTR as string data type. Is it okay to use C++11's u16string in my library? Are those two data types the same thing?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.