1 package ist.coach.coachEmfClientComponents.gui; 2 3 import javax.swing.JTable ; 4 import javax.swing.table.DefaultTableCellRenderer ; 5 import javax.swing.table.TableCellRenderer ; 6 import javax.swing.table.TableModel ; 7 import java.awt.Color ; 8 9 public class JAttributesTable 10 extends JTable { 11 12 DefaultTableCellRenderer editableRenderer; 13 DefaultTableCellRenderer readonlyRenderer; 14 DefaultTableCellRenderer attributeNameRenderer; 15 16 public JAttributesTable(TableModel dm) { 17 super(dm); 18 readonlyRenderer = new DefaultTableCellRenderer (); 19 readonlyRenderer.setForeground(Color.gray); 20 21 editableRenderer = new DefaultTableCellRenderer (); 22 23 attributeNameRenderer = new DefaultTableCellRenderer (); 24 attributeNameRenderer.setForeground(Color.blue); 25 attributeNameRenderer.setFont(new java.awt.Font ("Helvetica", 26 java.awt.Font.BOLD, 12)); 27 28 getTableHeader().setFont(new java.awt.Font ("Helvetica", 29 java.awt.Font.BOLD, 14)); 30 } 31 32 public TableCellRenderer getCellRenderer(int row, int column) { 33 34 if (column == 0) 35 return attributeNameRenderer; 36 37 if (getModel().isCellEditable(row, column)) 38 return editableRenderer; 39 else 40 return readonlyRenderer; 41 } 42 } 43 | Popular Tags |