1 package com.ca.directory.jxplorer.viewer.tableviewer; 2 3 import java.awt.Component ; 4 import javax.swing.JTable ; 5 import javax.swing.table.*; 6 import java.awt.*; 7 12 13 public class AttributeTypeCellRenderer extends DefaultTableCellRenderer 14 15 { 16 Font normalFont; 17 Font boldFont; 18 Font boldBlueFont; 19 23 public AttributeTypeCellRenderer() 24 { 25 super(); 26 normalFont = this.getFont(); 27 boldFont = normalFont.deriveFont(java.awt.Font.BOLD); 28 boldBlueFont = normalFont.deriveFont(java.awt.Font.BOLD); 29 } 30 31 35 public Component getTableCellRendererComponent(JTable table, Object value, 36 boolean isSelected, boolean hasFocus, int row, int column) 37 { 38 if (value instanceof AttributeType) 39 { 40 AttributeType attType = (AttributeType)value; 41 42 Component c = super.getTableCellRendererComponent(table, attType.getValue(), isSelected, hasFocus, row, column); 43 44 if (attType.isMandatory()) 45 { 46 c.setFont(boldFont); 47 } 48 else 49 { 50 c.setFont(normalFont); 51 } 52 return c; 53 54 } 55 else 56 return super.getTableCellRendererComponent(table, new String ("error"), isSelected, hasFocus, row, column); 57 } 58 } | Popular Tags |