Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8236907

JTable added to nested panels does not paint last visible row

    Details

    • Subcomponent:
    • Introduced In Version:
      9
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      A DESCRIPTION OF THE PROBLEM :
      There was code added to "BasicTableUI.paint(g, c)" between Java 8 and Java 12, which decrements the max row to paint. Unfortunately, when a JTable is nested within panels, it fails to paint the last visible row because of that new code.
      When clicking on the last visible row, eventually that one gets repainted.

      REGRESSION : Last worked in version 8

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Launch attached test case.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The table shows 3 rows.
      ACTUAL -
      The table shows 2 rows and a white row. Clicking on that white row forces it to paint.

      ---------- BEGIN SOURCE ----------
          public static void main(String[] args) throws Exception {
              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Container contentPane = frame.getContentPane();
              JPanel centerPane = new JPanel(new BorderLayout());
              centerPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
              JPanel tablePaneContainer = new JPanel(new BorderLayout());
              JPanel tablePane = new JPanel(new BorderLayout());
              JTable table = new JTable(new Object[][] {{"row_1_col_1", "row_1_col_2", "row_1_col_3"}, {"row_2_col_1", "row_2_col_2", "row_2_col_3"}, {"row_3_col_1", "row_3_col_2", "row_3_col_3"}, {"row_4_col_1", "row_4_col_2", "row_4_col_3"}}, new String[] {"Col1", "Col2", "Col3"});
              table.setPreferredSize(new Dimension(0, table.getRowHeight() * 3));
              tablePane.add(table.getTableHeader(), BorderLayout.NORTH);
              tablePane.add(table, BorderLayout.CENTER);
              tablePaneContainer.add(tablePane, BorderLayout.CENTER);
              centerPane.add(tablePaneContainer, BorderLayout.NORTH);
              contentPane.add(centerPane, BorderLayout.CENTER);
              frame.setSize(800, 600);
              frame.setVisible(true);
          }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

        1. 8u231-result.JPG
          8u231-result.JPG
          21 kB
        2. 9-14_result.JPG
          9-14_result.JPG
          18 kB
        3. BasicTableTest.java
          2 kB

          Activity

            People

            • Assignee:
              psadhukhan Prasanta Sadhukhan
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: