Code example for JLabel

Methods: getBackgroundgetText

0
    @Test
    public void testRenderCellWithNoConflicts() 
    { 
        TableCellRenderer renderer = new SudokuCellRenderer();
        JLabel cell = (JLabel) renderer.getTableCellRendererComponent(table, 1, false, false, 2, 1);
        assert cell.getText().equals("1") : "Wrong value at cell (2, 1): " + cell.getText();
        assert cell.getBackground() == Color.WHITE : "Cell without conflicts should be white.";
    } 
 
 
    @Test
    public void testRenderCellWithOneConflict() 
    { 
        TableCellRenderer renderer = new SudokuCellRenderer();
        JLabel cell = (JLabel) renderer.getTableCellRendererComponent(table, 3, false, false, 7, 1);
        assert cell.getText().equals("3") : "Wrong value at cell (7, 1): " + cell.getText();
        assert cell.getBackground() == Color.YELLOW : "Cell with one conflict should be yellow.";
    } 
 
 
Connect your IDE to all the code out there  Get Codota for Java