JDK 11 |
---|
11-poolResolved |
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
A DESCRIPTION OF THE PROBLEM : When trying to repaint a rectangle spanning more than a single row, parts of the affected rectangle just become blank instead of painting the actual content. The bug seems to be introduced due to changes made to BasicTableUI by "8081491: The case print incomplete." and "8159068: The rendering of JTable is broken". The issue is partly fixed in Java 12 by "8202702: Clearing selection on JTable causes disappearance of a row" but only when the repainted rectangle does not intersect more than a single row. The issue does not occur if a row is selected or the parent component of the table is a JScrollPane or a JViewPort. REGRESSION : Last worked in version 8u231 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Simply call JTable.repaint(Rectangle) with a rectangle spanning more than one row EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The containing area of the rectangle is repainted completely ACTUAL - Parts of the rectangle are not repainted and are left blank, showing only the background color. ---------- BEGIN SOURCE ---------- public static void main(String[] args) { JFrame frame = new JFrame(); TableModel model = new DefaultTableModel( new String[][] { { "A0", "B0" }, { "A1", "B1" }, { "A2", "B2" }, { "A3", "B3" } }, new String[] { "A", "B" }); JTable table = new JTable(model); frame.add(table); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setSize(200, 200); frame.setVisible(true); SwingUtilities.invokeLater(() -> repaintRows(table)); } private static void repaintRows(JTable table) { // get Rectangle for second row Rectangle r = table.getCellRect(1, 0, true); // expand cell rectangle to affect (parts of) third row r = new Rectangle(0, r.y, table.getWidth(), r.height * 2); table.repaint(r); } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Embedding the JTable into a JScrollPane or JViewPort. Alternatively simply repainting the whole table seems to work. FREQUENCY : always
|