JDK-8258969 : JTable rows not repainted when deeply nested in a JScrollPane
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 11
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86_64
  • Submitted: 2020-12-22
  • Updated: 2024-03-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11-poolUnresolved
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Observed in Java 11 Mac/Linux. Works correctly in Java 8 Mac/Linux

A DESCRIPTION OF THE PROBLEM :
When a JTable is wrapped in at least two JPanels, then displayed in a JScrollPane, the rows of the table are not drawn when scrolling. The table can be forced to update by selecting rows or minimizing/restoring the window.

REGRESSION : Last worked in version 8

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
(See attached test class)
Add a JScrollPane to a JFrame. Set the viewportview to a be a JPanel (panel A). Add a JPanel (panel B) to panel A, then add a JTable to panel B. The JTable needs to have enough rows for the scroll bars to be active.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successive table rows are drawn as the scroll pane is scrolled up and down.
ACTUAL -
Blank rows are drawn when scrolling with the touchpad. Rows are partially drawn when clicking and dragging the scroll bar.

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;

public class Main {
	
	private static class SampleTableModel extends AbstractTableModel {
        public int getColumnCount() { return 10; }
        public int getRowCount() { return 10;}
        public Object getValueAt(int row, int col) { if (row ==-10 && col==0) throw new IllegalArgumentException(); return Integer.valueOf(row*col); }
    };

	public static void main(String[] argv) {
		JFrame frame = new JFrame("scrollpane test");
		frame.setSize(400, 300);
		
		JPanel tables = new JPanel();
		tables.setLayout(new BoxLayout(tables, BoxLayout.Y_AXIS));
		
		for (int i = 0; i < 10; i++) {
			JPanel p = new JPanel(new BorderLayout());
			p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "title" + i));
			JTable table = new JTable(new SampleTableModel());
			tables.add(p);
			p.add(table);
		}
		
		JScrollPane sp = new JScrollPane(tables);
		frame.getContentPane().add(sp);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Only have one level of JPanel between the JScrollPane and JTable.

FREQUENCY : always



Comments
Checked with attached testcase in LOBI 7.6, issue is reproducible from 11 b01, not reproducible in 15, 16ea Test Result ======== 8u271: Pass 11 b01: Fail 11.0.9 : Fail 15 : Pass 16ea : Pass Attached screenshot for reference
28-12-2020