1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| public class CustomTableHeaderPainter<C extends JTableHeader, U extends WTableHeaderUI> extends TableHeaderPainter<C, U> {
public void setHeaderHeight(int headerHeight) { this.headerHeight = headerHeight; }
public void setTopBgColor(Color topBgColor) { this.topBgColor = topBgColor; }
public void setBottomBgColor(Color bottomBgColor) { this.bottomBgColor = bottomBgColor; }
public void setGridColor(Color gridColor) { this.gridColor = gridColor; }
@Override protected void paintCell ( final Graphics2D g2d, final C c, final Rectangle rect, final int columnIndex, final TableColumn column, final TableColumn draggedColumn, final TableColumnModel columnModel ) { final JTable table = c.getTable ();
final JScrollPane scrollPane = SwingUtils.getScrollPane ( table ); final boolean paintTrailingBorder = scrollPane != null && ( column == draggedColumn || table.getAutoResizeMode () == JTable.AUTO_RESIZE_OFF && scrollPane.getViewport ().getWidth () > table.getWidth () || ( ltr ? columnIndex != columnModel.getColumnCount () - 1 : columnIndex != 0 ) );
if ( ltr || paintTrailingBorder ) { g2d.setColor ( gridColor ); g2d.drawLine ( rect.x - 1, rect.y + 2, rect.x - 1, rect.y + rect.height - 4 ); }
final WebLabel headerRenderer = ( WebLabel ) getHeaderRenderer ( columnIndex ); headerRenderer.setStyleId(StyleId.label); headerRenderer.setOpaque ( false ); headerRenderer.setEnabled ( table == null || table.isEnabled () ); rendererPane.paintComponent ( g2d, headerRenderer, component, rect.x, rect.y, rect.width, rect.height, true );
if ( !ltr || paintTrailingBorder ) { g2d.setColor ( gridColor ); g2d.drawLine ( rect.x + rect.width - 1, rect.y + 2, rect.x + rect.width - 1, rect.y + rect.height - 4 ); } }
}
|