예제 #1
0
 RowHeaderRenderer(JTable table) {
   JTableHeader header = table.getTableHeader();
   setOpaque(true);
   setBorder(UIManager.getBorder("TableHeader.cellBorder"));
   setHorizontalAlignment(CENTER);
   setForeground(header.getForeground());
   setBackground(header.getBackground());
   setFont(header.getFont());
 }
예제 #2
0
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (table != null) {
        JTableHeader header = table.getTableHeader();

        if (header != null) {
          setForeground(header.getForeground());
          setBackground(header.getBackground());
          setFont(header.getFont());
        }
      }

      if (isSelected) {
        setFont(getFont().deriveFont(Font.BOLD));
      }

      setText((value == null) ? "" : value.toString());
      setBorder(UIManager.getBorder("TableHeader.cellBorder"));

      return this;
    }