/** * Returns the table cell background {@link Color} * * @param row the row number * @param column the column number */ @PublicAtsApi public Color getCellBackgroundColor( int row, int column ) { new SwingElementState(this).waitToBecomeExisting(); JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this); return tableFixture.backgroundAt(new TableCell(row, column) {}).target(); }
/** * Returns the table cell foreground {@link Color} * * @param row the row number * @param column the column number */ @PublicAtsApi public Color getCellForegroundColor( int row, int column ) { new SwingElementState(this).waitToBecomeExisting(); JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this); return tableFixture.foregroundAt(new TableCell(row, column) {}).target(); }
/** * Gets table cell backgrounds (as {@link Color}) of all table cells. * * @return array of java.awt.Color objects one for each cell. First index is * table row and second is the column in this row. */ @PublicAtsApi public Color[][] getCellBackgroundColors() { new SwingElementState(this).waitToBecomeExisting(); final JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this); int rowCount = tableFixture.rowCount(); // SwingUtilities. int columnCount = GuiActionRunner.execute(new GuiQuery<Integer>() { @Override protected Integer executeInEDT() throws Throwable { return tableFixture.component().getColumnCount(); } }); Color[][] resultArr = new Color[rowCount][columnCount]; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { resultArr[i][j] = tableFixture.backgroundAt(new TableCell(i, j) {}).target(); } } return resultArr; }