TableHeader: fixed position of column separators in right-to-left component orientation; do not paint anything if column count is zero

This commit is contained in:
Karl Tauber
2020-12-09 00:33:01 +01:00
parent 81c35eab46
commit cfbe44b946
2 changed files with 8 additions and 2 deletions

View File

@@ -5,6 +5,8 @@ FlatLaf Change Log
#### Fixed bugs
- TableHeader: Fixed position of column separators in right-to-left component
orientation.
- SwingX: Fixed striping background highlighting color (e.g. alternating table
rows) in dark themes.

View File

@@ -98,10 +98,13 @@ public class FlatTableHeaderUI
@Override
public void paint( Graphics g, JComponent c ) {
if( header.getColumnModel().getColumnCount() <= 0 )
return;
// do not paint borders if JTableHeader.setDefaultRenderer() was used
TableCellRenderer defaultRenderer = header.getDefaultRenderer();
boolean paintBorders = isSystemDefaultRenderer( defaultRenderer );
if( !paintBorders && header.getColumnModel().getColumnCount() > 0 ) {
if( !paintBorders ) {
// check whether the renderer delegates to the system default renderer
Component rendererComponent = defaultRenderer.getTableCellRendererComponent(
header.getTable(), "", false, false, -1, 0 );
@@ -168,7 +171,8 @@ public class FlatTableHeaderUI
g2.fill( new Rectangle2D.Float( x - lineWidth, topLineIndent, lineWidth, height - bottomLineIndent ) );
}
} else {
int x = width;
Rectangle cellRect = header.getHeaderRect( 0 );
int x = cellRect.x + cellRect.width;
for( int i = 0; i < sepCount; i++ ) {
x -= columnModel.getColumn( i ).getWidth();
g2.fill( new Rectangle2D.Float( x - (i < sepCount - 1 ? lineWidth : 0),