1

Need to check color/font style of java table (text, background) in Swing application cause style of row should depend on a column value.

styled jTable

It is possible to get color of font and background of selected (cell/row):

mainTable.selectCell(0, 0);
String bgcol = mainTable.getSelectionBackground().toString();  // => javax.swing.plaf.ColorUIResource[r=51,g=153,b=255]
String fgcol = mainTable.getSelectionForeground().toString();  // => javax.swing.plaf.ColorUIResource[r=255,g=255,b=255]    

But selected cell/row has its own style of selection, so this check becomes quite useless.

What is the way to accomplish style checking of any cell/row (not just selected) with Jemmy library?

1 Answer 1

0

A renderer is used to paint each cell in the table. Code to access the component used to render the cell:

TableCellRenderer renderer = table.getCellRenderer(row, column);
Component c = table.prepareRenderer(renderer, row, column);
System.out.println(c.getBackground());
System.out.println(c.getForeground());
System.out.println(c.getFont());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.