dshrenik
asked on
Swing: JTable with JLabel and images
Please let me know how I can create a JTable with JLabels and images.
I want a 4X3 table with jlabels in the first 2 columns and images in the third column.
If possible, please provide some sample code.
Thanks!
I want a 4X3 table with jlabels in the first 2 columns and images in the third column.
If possible, please provide some sample code.
Thanks!
ASKER
I am not sure how I can use JLabels and images inside a table. If possible, can you provide some sample code? Thanks!
Table cell renderer retrns Component in this method:
public Component getTableCellRendererCompon ent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
you should define this method so that you'll check row and column and either
return smple Lavble for some columns or return say JPanel
showing the image depeneding on the value of parameter column
public Component getTableCellRendererCompon
boolean isSelected, boolean hasFocus, int row, int column) {
you should define this method so that you'll check row and column and either
return smple Lavble for some columns or return say JPanel
showing the image depeneding on the value of parameter column
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You need to use TableCellRendereere
This is an example:
http://www.java2s.com/Code/Java/Swing-JFC/TableRendererSample.htm