Skip to content

Commit 531a3f4

Browse files
committed
Fix: avoid bug https://bugs.openjdk.java.net/browse/JDK-8013564 (anti-aliased text on translucent images isn't smooth). Cached images would be opaque, so anti-aliasing would work.
1 parent 8b9cc75 commit 531a3f4

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/org/quinto/swing/table/view/JBroTableHeaderUI.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,10 @@ private void paintCell( Graphics g, Rectangle cellRect, JBroTableColumn group )
530530
comp = customRenderer.getTableCellRendererComponent( comp, table, value, rollover, rollover, group == getHeader().getDraggedGroup(), row, viewColumn, modelColumn, dataField );
531531
}
532532
if ( isCacheUsed() ) {
533-
Image image = new BufferedImage( cellRect.width, cellRect.height, BufferedImage.TYPE_INT_ARGB );
533+
Image image = new BufferedImage( cellRect.width, cellRect.height, BufferedImage.TYPE_INT_RGB );
534534
Graphics gg = image.getGraphics();
535+
gg.setColor( header.getParent().getBackground() );
536+
gg.fillRect( 0, 0, cellRect.width, cellRect.height );
535537
gg.translate( -cellRect.x, -cellRect.y );
536538
paintCell( gg, comp, cellRect );
537539
g.drawImage( image, cellRect.x, cellRect.y, null );

src/org/quinto/swing/table/view/JBroTableUI.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public void setCacheUsed( boolean cacheUsed ) {
6868
}
6969

7070
void setRowsScrolling( boolean rowsScrolling ) {
71+
if ( !isCacheUsed() )
72+
rowsScrolling = true;
7173
if ( !this.rowsScrolling && rowsScrolling )
7274
clearCellImagesCache();
7375
this.rowsScrolling = rowsScrolling;
@@ -387,8 +389,10 @@ private void paintDraggedArea( Graphics g, int rMin, int rMax, JBroTableColumn d
387389
}
388390
Graphics gg;
389391
if ( isCacheUsed() ) {
390-
draggedAreaCache = new BufferedImage( vacatedColumnRect.width + 1, vacatedColumnRect.height, BufferedImage.TYPE_INT_ARGB );
392+
draggedAreaCache = new BufferedImage( vacatedColumnRect.width + 1, vacatedColumnRect.height, BufferedImage.TYPE_INT_RGB );
391393
gg = draggedAreaCache.getGraphics();
394+
gg.setColor( table.getParent().getBackground() );
395+
gg.fillRect( 0, 0, vacatedColumnRect.width + 1, vacatedColumnRect.height );
392396
gg.translate( 1 - vacatedColumnRect.x, -vacatedColumnRect.y );
393397
} else
394398
gg = g;
@@ -488,8 +492,10 @@ private void paintCell( Graphics g, Rectangle cellRect, int row, int column, Obj
488492
gg = g;
489493
image = null;
490494
} else {
491-
image = new BufferedImage( cellRect.width, cellRect.height, BufferedImage.TYPE_INT_ARGB );
495+
image = new BufferedImage( cellRect.width, cellRect.height, BufferedImage.TYPE_INT_RGB );
492496
gg = image.getGraphics();
497+
gg.setColor( table.getParent().getBackground() );
498+
gg.fillRect( 0, 0, cellRect.width, cellRect.height );
493499
gg.translate( -cellRect.x, -cellRect.y );
494500
}
495501
gg.setColor( header != null ? header.getBackground() : isSelected ? table.getSelectionBackground() : table.getBackground() );

0 commit comments

Comments
 (0)