Community
Participate
Working Groups
I am encountering a wrong behavior of the getTopIndex() method of Table class. Lets say we have a table with 20 fully visible rows and one more row that is not fully visible. Does not matter how much of this last row is visible. What is important is that the user can select it using his mouse if he wants to. We have two scenarios: Scenario 1: Lets say that last visible row is already selected.The user presses down arrow key, making the table to select the row which was not fully visible and bring it one row above in the UI in order for the user to see it completely. In this scenario the getTopIndex() returns a value equal to: "index of selected row - 20 - 1" Scenario 2: The user selects the row which is not fully visible via a mouse click making the table to bring it one row above in the UI in order for the user to see it completely. In this scenario the getTopIndex() returns a value equal to: "index of selected row - 20" As you can see the difference between the two values is 1. In my opinion this is wrong. It should return the same value.
Created attachment 244329 [details] TestSnippet to reproduce this problem
A possible workaround would be to use combination of KeyListerer & MouseListener instead of SelectionListener to get consistent value from Table#getTopIndex() : table.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { System.out.println("KeyPressed: [" + table.getTopIndex() + "]"); } }); table.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { System.out.println("MouseDown: [" + table.getTopIndex() + "]"); } });
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
Its true what they say, that time fixes all things. Thank you for looking into the actual problem raised.