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

Moving columns in JTable header, mouse + column location decouple

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6u10
    • Fix Version/s: None
    • Component/s: client-libs

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_10"
      Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
      Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux <username> 2.6.27-7-generic #1 SMP Tue Nov 4 19:33:20 UTC 2008 i686 GNU/Linux


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      No additional configuration.

      A DESCRIPTION OF THE PROBLEM :
      You can reorder columns in java by clicking on a column in the column header and dragging it to a new location and releasing the mouse to drop it. When this happens, you get an overlay image of the column that follows the mouse and its location in the table is marked by a blank spacer. As the mouse moves the image tracks the mouse location pixel by pixel, but the blank spacer / drop location only moves when half of the image overlay crosses onto an adjacent column, i.e. when the mouse has moved past a certain threshold point.

      When you drag a column but move the mouse quickly, the blank spacer gets decoupled from the mouse position and you can get into the state where the mouse with the column overlay is at one end of the table and the column spacer part way / no where near the mouse. Then when you release the mouse to drop the column, it slots into where the spacer is - nowhere near the mouse / intended drop location.

      If you drag quickly and get it in the decoupled state, but hold on to the column and slowly move / wiggle you mouse. The blank spacer will start jumping closer and closer with every movement, until it reaches a the correct state.

      The problem seems to get more common with more columns (slower mouse movements cause the problem). Although, this might be because column widths are getting smaller. My guess would be that on a mouse movement event, the JTable looks at the mouse location and if it is past the threshold point for the next move, will increment / decrement the column index (i.e. by 1). So per mouse event the column index can adjusted by 1, so if you move the mouse fast enough and its translation is bigger than the width of a couple of columns then you can see how the actual column index will fall behind / decouple. This would also explain how wiggling the mouse makes the blank space get closer in single increments.

        To clarify, I'm not talking about mouse extreme speeds. In a real application with a table (~15-20 columns) expanded across the whole screen (widescreen / 1650x1050 resolution) I regularly observe this problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached code or just create a frame with a table in it with 20 columns + 500pixels wide. Click and hold on a column header to drag, quickly move the mouse to the other side of the table in 1 movement - to relocate the column there. Note: movement must be made fairly quickly, if having trouble try adding more columns or reducing width slightly.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The column should drag accross to the other side of the screen, with the blank spacer behind it. Releasing the mouse and the column should fall back into the table/spacer at / around the location of the mouse.
      ACTUAL -
      The mouse + column image overlay move to the other side of the screen. However, the blank column spacer and the actual column index are not where the mouse is and only moved part way down the table. On releasing the mouse, the column goes falls back into the table where the spacer is / nowhere near the mouse - the intended drop location.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error messages.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /**
      * Moving columns in JTable header, mouse + column location decouple
      *
      * To reproduce:
      * Run the attached code. Click and hold on a column header to drag,
      * quickly move the mouse to the other side of the table in 1 movement -
      * to relocate the column there. Note: movement must be made fairly quickly, if
      * you cant observe, try reducing the width slighly or adding more columns
      *
      * Expected:
      * The column should drag accross to the other side of the screen, with the blank
      * spacer behind it. Releasing the mouse and the column should fall back into the
      * table/spacer at / around the location of the mouse.
      *
      * Observed:
      * The mouse + column image overlay move to the other side of the screen. However,
      * the blank column spacer and the actual column index are not where the mouse is and
      * only moved part way down the table. On releasing the mouse, the column goes falls
      * back into the table where the spacer is / nowhere near the mouse - the intended drop
      * location.
      *
      * @author RT
      */
      public static void main(String[] args) {
      // create a default table with 20 columns and add to a scrollpane
      JTable table = new JTable(0, 20);
      JScrollPane tablePane = new JScrollPane(table);

      // create/setup a frame, add table containing scrollpane.
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setContentPane(tablePane);
      frame.setSize(600,500);
      frame.setVisible(true);
      }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ryeung Roger Yeung (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: