Click to See Complete Forum and Search --> : JTable troubles


Chris Gurney
January 15th, 1999, 01:14 PM
I've got some code which attemps to display a JPanel within a JTable cell, but instead the output from a JPanel.toString() appears there instead. Any ideas as to what could be wrong?


Thanks,

Chris.

Chris Gurney
January 15th, 1999, 02:35 PM
Forget it.

I was trying to follow Java 2 examples using Java 1.1.6.

It didn't quite work. ;)


Chris

Vishwa Malhotra
June 15th, 1999, 03:34 PM
The default JTable renderer (Class based rendering) handles String, boolean and numbers.

Typically one needs to do the following
1) Create your class implementing TableCellRenderer interface and extending from any JComponent subclass (In your case extends JPanel)
2) Set the instance of the this class to the appropiate column.

e.g., <table_name>.getColumnModel().getColumn(0).setCellRenderer(<your_class>);

This should do the job.

Thanks