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

Autoscrolling while reordering columns using Drag&Drop with a JTable/JScrollPane

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 6
    • client-libs

      FULL PRODUCT VERSION :
      java version "1.6.0"
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

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

      A DESCRIPTION OF THE PROBLEM :
      If AutoResize is set to off for the JTable and you try to reorder the columns using Drag & Drop while the horizontal scroll bar is moved to the right a bit... The horizontal scroll bar will auto-scroll back to the left most position, making it impossible to order the columns how you want.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached source code... scroll to the right a little... and try to reorder the columns.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The scroll bar would stay stationary as I reorder the columns... as it did in previous versions of Java
      ACTUAL -
      The scroll bar auto-scrolled back to the left

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com.qw.utilities;

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

      public class ColumnReorder {
      private static void doTableTest() {
           DefaultTableModel mod = new DefaultTableModel(new String[] {"Column 1", "Column 2"
           , "Column 3", "Column 4", "Column 5", "Column 6", "Column 7", "Column 8"
           , "Column 9", "Column 10", }, 0);
           JTable tbl = new JTable(mod);
           tbl.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
           JFrame frm = new JFrame("Demo Column Reorder problem");
           frm.getContentPane().add(new JScrollPane(tbl));
           frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frm.setSize(250, 250);
           frm.setVisible(true);
          }
          
      public static void main(String[] args) throws Exception {
      doTableTest();
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None that I have found yet.

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

            shickeysunw Shannon Hickey (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: