Program: 51555
Project: 51555
Buggy source:
/** 
 * Sets the viewport of a certain table so that the given line is visible.
 * @param line  Number of the line, that is wanted to be visible.
 * @param table The table. Valid values for this parameter are CODE_TABLEand INSTRUCTIONS_AND_DATA_TABLE
 * @return True if the operation was successful.False if the line number was not valid - ie there's no such line in the table or there's no such table.
 */
public boolean centerToLine(int line,short table){
  JScrollPane activeScrollPane=null;
  JTableX activeTable=null;
switch (table) {
case CODE_TABLE:
    if (line >= codeTable.getRowCount() || line < 0) {
      return false;
    }
  activeScrollPane=codeTableScrollPane;
activeTable=codeTable;
break;
case INSTRUCTIONS_AND_DATA_TABLE:
if (line >= (instructionsTable.getRowCount() + dataTable.getRowCount()) || line < 0) {
return false;
}
if (line < instructionsTable.getRowCount()) {
activeScrollPane=instructionsTableScrollPane;
activeTable=instructionsTable;
}
 else {
activeScrollPane=dataTableScrollPane;
activeTable=dataTable;
line-=instructionsTable.getRowCount();
}
break;
default :
break;
}
if (activeScrollPane == null || activeTable == null) {
return false;
}
int tableViewHeight=activeScrollPane.getHeight() - activeTable.getTableHeader().getHeight();
int y;
if (tableViewHeight > activeTable.getHeight()) {
y=0;
}
 else {
y=line * activeTable.getRowHeight() - tableViewHeight / 2 + activeTable.getRowHeight() / 2;
y=(y < 0) ? 0 : y;
if (y + tableViewHeight > activeTable.getHeight()) {
y=activeTable.getHeight() - tableViewHeight + activeTable.getRowMargin() + 2;
}
}
activeScrollPane.getViewport().setViewPosition(new Point(0,y));
return true;
}

Fixed version (ground truth):
/** 
 * Sets the viewport of a certain table so that the given line is visible.
 * @param line  Number of the line, that is wanted to be visible.
 * @param table The table. Valid values for this parameter are CODE_TABLEand INSTRUCTIONS_AND_DATA_TABLE
 * @return True if the operation was successful.False if the line number was not valid - ie there's no such line in the table or there's no such table.
 */
protected void centerToLine(final int ln,final short table){
  SwingUtilities.invokeLater(new Runnable(){
    int line=ln;
    public void run(){
      JScrollPane activeScrollPane=null;
      JTableX activeTable=null;
switch (table) {
case CODE_TABLE:
        if (line >= codeTable.getRowCount() || line < 0) {
          return;
        }
      activeScrollPane=codeTableScrollPane;
    activeTable=codeTable;
  break;
case INSTRUCTIONS_AND_DATA_TABLE:
if (line >= (instructionsTable.getRowCount() + dataTable.getRowCount()) || line < 0) {
  return;
}
if (line < instructionsTable.getRowCount()) {
activeScrollPane=instructionsTableScrollPane;
activeTable=instructionsTable;
}
 else {
activeScrollPane=dataTableScrollPane;
activeTable=dataTable;
line-=instructionsTable.getRowCount();
}
break;
default :
break;
}
if (activeScrollPane == null || activeTable == null) {
return;
}
int tableViewHeight=activeScrollPane.getHeight() - activeTable.getTableHeader().getHeight();
int y;
if (tableViewHeight > activeTable.getHeight()) {
y=0;
}
 else {
y=line * activeTable.getRowHeight() - tableViewHeight / 2 + activeTable.getRowHeight() / 2;
y=(y < 0) ? 0 : y;
if (y + tableViewHeight > activeTable.getHeight()) {
y=activeTable.getHeight() - tableViewHeight + activeTable.getRowMargin() + 2;
}
}
activeScrollPane.getViewport().setViewPosition(new Point(0,y));
return;
}
}
);
}