@@ -777,6 +777,9 @@ else if( value instanceof int[] )
777777
778778 @ SuppressWarnings ( "FormatString" ) // Error Prone
779779 private static String color2hex ( Color color ) {
780+ if ( color == null )
781+ return "" ;
782+
780783 int rgb = color .getRGB ();
781784 boolean hasAlpha = color .getAlpha () != 255 ;
782785
@@ -1018,28 +1021,36 @@ public Component getTableCellRendererComponent( JTable table, Object value,
10181021 item = (Item ) value ;
10191022 init ( table , item .key , isSelected , row );
10201023
1021- // reset background, foreground and icon
1022- if ( !(item .value instanceof Color ) ) {
1024+ // get color of value
1025+ valueColor = null ;
1026+ if ( item .value instanceof Color )
1027+ valueColor = (item .info instanceof Color []) ? ((Color [])item .info )[0 ] : (Color ) item .value ;
1028+ else if ( item .value instanceof FlatLineBorder )
1029+ valueColor = ((FlatLineBorder )item .value ).getLineColor ();
1030+
1031+ // reset background and foreground
1032+ if ( valueColor == null ) {
10231033 setBackground ( null );
10241034 setForeground ( null );
10251035 }
1026- if ( !(item .value instanceof Icon ) )
1027- setIcon ( null );
10281036
10291037 // value to string
10301038 value = item .getValueAsString ();
10311039
10321040 super .getTableCellRendererComponent ( table , value , isSelected , hasFocus , row , column );
10331041
1034- if ( item .value instanceof Color ) {
1035- Color color = (item .info instanceof Color []) ? ((Color [])item .info )[0 ] : (Color ) item .value ;
1036- boolean isDark = new HSLColor ( color ).getLuminance () < 70 && color .getAlpha () >= 128 ;
1037- valueColor = color ;
1042+ // set foreground, if value has color
1043+ if ( valueColor != null ) {
1044+ boolean isDark = new HSLColor ( valueColor ).getLuminance () < 70 && valueColor .getAlpha () >= 128 ;
10381045 setForeground ( isDark ? Color .white : Color .black );
1039- } else if ( item .value instanceof Icon ) {
1046+ }
1047+
1048+ // set icon
1049+ if ( item .value instanceof Icon ) {
10401050 Icon icon = (Icon ) item .value ;
10411051 setIcon ( new SafeIcon ( icon ) );
1042- }
1052+ } else
1053+ setIcon ( null );
10431054
10441055 // set tooltip
10451056 String toolTipText = (item .value instanceof Object [])
@@ -1056,7 +1067,7 @@ public Component getTableCellRendererComponent( JTable table, Object value,
10561067
10571068 @ Override
10581069 protected void paintComponent ( Graphics g ) {
1059- if ( item . value instanceof Color ) {
1070+ if ( valueColor != null ) {
10601071 int width = getWidth ();
10611072 int height = getHeight ();
10621073 Color background = valueColor ;
0 commit comments