Note that there are some explanatory texts on larger screens.

plurals
  1. POSwingX JXTable Boolean column have different color on highlight
    text
    copied!<p>I have a little problem with SwingX Components.</p> <p>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.</p> <p>I want that all columns were highlighted in the same color.</p> <p>Have anyone an idea to solve the problem? </p> <hr> <p><img src="https://i.stack.imgur.com/y9h8F.png" alt=""></p> <hr> <p><code> </p> <pre><code>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&lt;?&gt; getColumnClass( int columnIndex ) { switch ( columnIndex ) { case 0: return String.class; case 1: return Boolean.class; default : return Object.class; } } } </code></pre> <p></code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload