I have a little problem with SwingX Components.
In my Application I’m using a JXTable and on the table I register a MouseOver ColorHighlighter. The model of the table defines two columns; a String column and a Boolean column. The default renderers of a Boolean column in a JXTable are CheckBoxes. Now the Problem is when the Mouse moves over the rows the ColorHighlighter highlights the columns in different colors; the Boolean column is darker then the String column. In the Example you can see the behavior.
I want that all columns were highlighted in the same color.
Have anyone an idea to solve the problem?
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.table.DefaultTableModel;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.HighlightPredicate;
public class BooleanHighlighterDemo
{
public static void main( String args[] )
{
JFrame frame = new JFrame( "Boolean Highlighter" );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
JXTable table = new JXTable( new BooleanTableModel() );
//Add ColorHighlighter
table.addHighlighter( new ColorHighlighter( HighlightPredicate.ROLLOVER_ROW,
new Color( 0x330000ff, true ), Color.BLACK ) );
frame.add( new JScrollPane( table ), BorderLayout.CENTER );
frame.setSize( 400, 150 );
frame.setVisible( true );
}
}
class BooleanTableModel extends DefaultTableModel
{
public BooleanTableModel()
{
super( new Object[][]{ { "1", Boolean.TRUE }, { "2", Boolean.TRUE }, { "3", Boolean.FALSE },
{ "4", Boolean.TRUE }, { "5", Boolean.FALSE } }, new String[]{ "Number", "Boolean" } );
}
@Override
public Class<?> getColumnClass( int columnIndex )
{
switch ( columnIndex )
{
case 0:
return String.class;
case 1:
return Boolean.class;
default :
return Object.class;
}
}
}