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,107
  • 18
  • 130
  • 305
Jeetesh Nataraj
  • 598
  • 2
  • 7
  • 19

2 Answers2

2

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

Community
  • 1
  • 1
mKorbel
  • 109,107
  • 18
  • 130
  • 305
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
  • 200,320
  • 28
  • 229
  • 974