2

I have JTable of order nxn with the JScrollPane size being

JScrollPane jsc = new JScrollPane(table);
        jsc.setPreferredSize(new Dimension(500,700));

The Scenario is this:: whenever I edit the last cell (it contains a JTextField) of the JTable by dragging down the ScrollBar and come out of Focus, the ScrollBar slides back the original position, i.e the beginning position. I would like the ScrollBar be in the place where it was set by the user before and after editing.... how can this be achieved?

Thank You In Advance....

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Jeetesh Nataraj
  • 608
  • 2
  • 8
  • 20

2 Answers2

2

you can able to determine scrollToVisible(JTable table, int rowIndex, int vColIndex), example here

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319
2

Because JTable is a Scrolling-Savvy Client, it implements the Scrollable interface. You may get better results using the method setPreferredScrollableViewportSize() instead of calling setPreferredSize() directly on the scroll pane.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045