I need to add checkboxes to a JTree. A custom TreeCellRenderer/TreeCellEditor seems like the right approach. So far I used the CheckBoxNodeRenderer approach in this webpage.
per @aperkins suggestion this is what I ended up doing in the TableCellRenderer, it seems to work well:
final private JPanel nodeRenderer = new JPanel();
final private JLabel label = new JLabel();
final private JCheckBox check = new JCheckBox();
...
// in constructor:
final Insets inset0=new Insets(0,0,0,0);
this.check.setMargin(inset0);
this.nodeRenderer.setLayout(new BorderLayout());
this.nodeRenderer.add(this.check, BorderLayout.WEST);
this.nodeRenderer.add(this.label, BorderLayout.CENTER);
The keys for getting rid of unwanted space in the margins seems to be (a) calling JCheckBox.setMargin() to reduce the checkbox margin, and (b) using a BorderLayout for JPanel.