cellrenderer

Custom TableCellRenderer not working (table row rendering)

折月煮酒 提交于 2019-11-28 09:48:11
问题 I'm trying to render an specific row of my jtable (it should have a different background color and it should have bold characters). I found several questions regarding how to implement a custom TableCellRenderer (here and here) and the tutorial How to Use Tables and this one (Table Row Rendering). I'm using a JInternalFrame to display the JTable . I tried to implement both solutions but neither getCellRenderer nor prepareRenderer are being called. When debugging, I can see my new jtable being

How to set icon in a column of JTable?

二次信任 提交于 2019-11-27 02:02:25
I am able to set the column's header but not able to set icon in all the rows of first column of JTable. public class iconRenderer extends DefaultTableCellRenderer{ public Component getTableCellRendererComponent(JTable table,Object obj,boolean isSelected,boolean hasFocus,int row,int column){ imageicon i=(imageicon)obj; if(obj==i) setIcon(i.imageIcon); setBorder(UIManager.getBorder("TableHeader.cellBorder")); setHorizontalAlignment(JLabel.CENTER); return this; } } public class imageicon{ ImageIcon imageIcon; imageicon(ImageIcon icon){ imageIcon=icon; } } and below lines in my BuildTable()