This discussion is archived
3 Replies Latest reply: Aug 28, 2012 1:46 AM by 896639 RSS

Handling behaviour of Ctrl - End of JTable

896639 Newbie
Currently Being Moderated
I use JTable to show the data. Since i have a huge list of data, we load data lazily, Initially the data is loaded and shown that fits the screen and then upon scroll down we load the required data . In the current scenario, when the user presses Ctrl - End, it only selects the last loaded record [Only data that is loaded so far/ last record seen on the screen], rather what i want to achieve is, handle the Ctrl - End and then load all the data and then select the last (really last) record.

Thanks,

Sarat.
  • 1. Re: Handling behaviour of Ctrl - End of JTable
    sabre150 Expert
    Currently Being Moderated
    ryaliscs wrote:
    I use JTable to show the data. Since i have a huge list of data, we load data lazily,
    I always consider this approach to viewing a 'huge list of data' as being flawed. It seems silly to me to get the user to scroll through hundreds or thousands of lines to find a particular line. It is normally better to only show the lines that match some search criteria.

    As for the rest of your requirement . Since we have no view of your code, only you know enough about your design and code to stand a chance of suggesting the changes necessary.
  • 2. Re: Handling behaviour of Ctrl - End of JTable
    800268 Expert
    Currently Being Moderated
    You can put your own action in the table's action map, using the keys in BasicTableUI#Actions.
  • 3. Re: Handling behaviour of Ctrl - End of JTable
    896639 Newbie
    Currently Being Moderated
    I also found another approach of handling the behaviour by adding a key listener to the JTable. eg:


    private class MyTableKeyListener extends KeyAdapter
    {
    /**
    * {@inheritDoc}
    */
    @Override public void keyPressed(KeyEvent aEvent)
    {
    if ((KeyEvent.VK_END == aEvent.getKeyCode()) && aEvent.isControlDown())
    {
    .....
    }
    }
    }

    ...
    myTable.addKeyListener(new MyTableKeyListener());
    .....

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points