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

REGRESSION:Mouse wheel scrolling does not work if a table has zero width columns

XMLWordPrintable

    • 6
    • b80
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59g)
      Java HotSpot(TM) Client VM (build 1.6.0-beta-b59g, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      If a JTable has one or more zero width columns, horizontal scrolling using mouse wheel does not work properly.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run TableWheel ( see below ). A window will open with a simple JTable in it that has a column with zero width. Scroll the table to the right using the mouse wheel. After that scroll the table to the left using the mouse wheel as well. You will see that the scrolling stops at column 3, it does not go to the left end of the table.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package bugs;

      import java.awt.Dimension;
      import java.awt.Toolkit;

      import javax.swing.JFrame;
      import javax.swing.JScrollPane;
      import javax.swing.JTable;

      public class TableWheel {

          public static void main(String[] args) {
              JFrame frame = new JFrame("Mustang Swing Bug");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.add(new JScrollPane(TableWheel.getJTable()));
              Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
              frame.setBounds((screen.width-300)/2,(screen.height-200)/2,300,200);
              frame.setVisible(true);
          }
          
          public static JTable getJTable() {
              Object[][] data = {
                      {"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"},
                      {"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"}
                      };
              Object[] columns = {"Col1", "Col2", "Col3", "Col4", "Col5", "Col6", "Col7", "Col8", "Col9", "Col10"};
              int[] widths = {100, 0, 100, 100, 100, 100, 100, 100, 100, 100};
              
              JTable table = new JTable(data, columns);
              table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
              
              for (int i = 0; i < table.getColumnCount(); i++) {
                  table.getColumn(table.getColumnName(i)).setPreferredWidth(widths[i]);
                  table.getColumn(table.getColumnName(i)).setWidth(widths[i]);
                  if(widths[i] == 0) {
                      table.getColumn(table.getColumnName(i)).setMinWidth(0);
                      table.getColumn(table.getColumnName(i)).setMaxWidth(0);
                  } else {
                      table.getColumn(table.getColumnName(i)).setMinWidth(10);
                  }
              }
              
              return table;
          }

      }

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

      Release Regression From : 5.0
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

            bchristi Brent Christian
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: