How to get colour, font of java table row/cell/text with Jemmy?



  • 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?



  • 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());
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2