my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes setting up JCheckBox in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setting up JCheckBox in JTable" Watch "setting up JCheckBox in JTable" New topic
Author

setting up JCheckBox in JTable

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Hi there,

I'm setting up a column in JTable that contains JCheckBoxes. I use the following renderer and editor to achieve this. It all works fine except when I click on a cell containing a JCheckBox, which initially appears centered in the cell, it suddenly moves to the left of the cell. I'd like it to stay where it is. Please advise.

Alan

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2203
    
    7
There is no need to create a custom render and editor. JTable provides default implementations for this. Just override the getColumnClass(....) method to return Boolean for that column and the default renderer/editor will be used.
 
 
subject: setting up JCheckBox in JTable