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

Bug: JTable - getSelectedColumn() Row() - With MouseListener

    Details

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

      Description

      FULL PRODUCT VERSION :
      JDK 1.6.0_17 - b04

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP sp2

      A DESCRIPTION OF THE PROBLEM :
      When you addMouseListener to JTable and using getSelectedColumn(), getSelectedRow()

      the result after you release will be wrong in case of
      - press and move to the right
      - press and move to the down

      ex prob1. when you press on position 1,1 and release on 1,2 result is 1,1
      ex prob2. when you press on position 1,1 and release on 2,1 result is 1,1
      ex prob3. when you press on position 1,1 and release on 2,2 result is 1,1

      if move to the left and top is still fine
      ex. when you press on position 1,1 and release on 0,1 result is 0,1
      ex. when you press on position 1,1 and release on 1,0 result is 1,0
      ex. when you press on position 1,1 and release on 0,0 result is 0,0



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create class extends JFrame implements MouseListener
      2. create jtable addmouselistener to it
      3. concentrate in mousepress and mousereleased
      mousePressed(MouseEvent e)
      {
      System.out.println(table.getSelectedColumn() +", "+ table.getSelectedRow());
      }
      mouseReleased(MouseEvent e)
      {
      System.out.println(table.getSelectedColumn() +", "+ table.getSelectedRow());
      }
      4. try to release on top, down, left, right

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      result will show the row,column when mouse press not on mouse released
      * when released on left or/and down position from pressed
      ACTUAL -
      it should show the proper row,column when mouse released

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
      Author: Sruit Angkavanitsuk
      */
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      class JTableBug extends JFrame implements MouseListener
      {
      JTable table = new JTable(5,5);

      JTableBug()
      {
      add(table);
      setVisible(true);
      setSize(300,300);
      table.addMouseListener(this);
      }
      public void mouseClicked(MouseEvent e){}
      public void mousePressed(MouseEvent e)
      {
      System.out.println("Pressed:"+table.getSelectedRow() +","+ table.getSelectedColumn());
      }
      public void mouseReleased(MouseEvent e)
      {
      System.out.println("Released:"+table.getSelectedRow() +","+ table.getSelectedColumn());
      }
      public void mouseEntered(MouseEvent e){}
      public void mouseExited(MouseEvent e){}
      public static void main(String[] args)
      {
      new JTableBug();
      }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      fix ur algorithm : ]

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: