Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JTable jcheckbox

Status
Not open for further replies.

tictaclam

Programmer
Jan 8, 2004
47
US
Hi
I have a jtable that has buttons, jtextfield, and check boxes in cell depending on the data. I had to extend defaultTableRenderer and extend abstractCellEditor to do this. Everything is working great except I can't seem to center the check boxes. I tried adding the line
Code:
 setHorizontalAlignment (SwingConstants.CENTER);
in the getTableCellRendererComponent method in the class that extends the DefaultTableCellRenderer. This isn't working. Is there something else i need to set? thanks
 
I love how Swing makes these things possible!

Your post is vague as to how you are handling the components which appear in the table cells, but have you set that horizontal alignment on the checkbox itself?
Code:
JCheckBox chkbox = new JCheckBox();
chkbox.setHorizontalAlignment ( SwingConstants.CENTER );

It might help if you posted the actual renderer class if it's not too big. Or at least the salient bits of it.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top