0

Hi everybody I'am kind of a noob using java.swing and I would like to know if you could help me with the following issue:

  • I have a JFrame containing several JPanels where each JPanel is an eyelash with their own JTable.

  • In each JTable there are double type values referring to € amounts.

  • In a static variable I keep the max value of all the eyelash.

So my point is that I want to use a JButton that takes me to the eyelash and the row where I have the max value.

In example: If max value is in eyelash 3, row 55 I want that when pressing the button the programs takes me to visualize this row.

Thanks in advance.

Xaloc
  • 3
  • 1
  • Possible duplicate of [How to set Focus to the first row in a JTable which is inside a JScrollPane](http://stackoverflow.com/questions/11365294/how-to-set-focus-to-the-first-row-in-a-jtable-which-is-inside-a-jscrollpane) – Azodious Jan 10 '17 at 12:17
  • 1
    Possible duplicate of [JTable Scrolling to a Specified Row Index](http://stackoverflow.com/questions/853020/jtable-scrolling-to-a-specified-row-index) – Sergiy Medvynskyy Jan 10 '17 at 12:34

1 Answers1

2

For example you want to select the row x

Rectangle rect = myTable.getCellRect(x, 0, true);
myTable.scrollRectToVisible(rect); // scroll to the row
myTable.getSelectionModel().setSelectionInterval(x, x); // and select it (when required)
Sergiy Medvynskyy
  • 11,160
  • 1
  • 32
  • 48