Skip to content

Commit

Permalink
Table: fixed cell focus indicator border hiding for boolean columns (…
Browse files Browse the repository at this point in the history
…issue #654)
  • Loading branch information
DevCharly committed Mar 28, 2023
1 parent d27a246 commit 2e878b6
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.plaf.TableUI;

/**
Expand Down Expand Up @@ -107,6 +108,28 @@ public void paintBorder( Component c, Graphics g, int x, int y, int width, int h
public static class Focused
extends FlatTableCellBorder
{
@Override
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
if( c != null && c.getClass().getName().equals( "javax.swing.JTable$BooleanRenderer" ) ) {
// boolean renderer in JTable does not use Table.focusSelectedCellHighlightBorder
// if cell is selected and focused (as DefaultTableCellRenderer does)
// --> delegate to Table.focusSelectedCellHighlightBorder
// to make FlatLaf "focus indicator border hiding" work
JTable table = (JTable) SwingUtilities.getAncestorOfClass( JTable.class, c );
if( table != null &&
c.getForeground() == table.getSelectionForeground() &&
c.getBackground() == table.getSelectionBackground() )
{
Border border = UIManager.getBorder( "Table.focusSelectedCellHighlightBorder" );
if( border != null ) {
border.paintBorder( c, g, x, y, width, height );
return;
}
}
}

super.paintBorder( c, g, x, y, width, height );
}
}

//---- class Selected -----------------------------------------------------
Expand Down

0 comments on commit 2e878b6

Please sign in to comment.