if (index < (tabs - 2)) { frame.sessionPane.setSelectedIndex(index); frame.sessionPane.setForegroundAt(index,Color.blue); frame.sessionPane.setIconAt(index,focused); } else {  frame.sessionPane.setSelectedIndex(0); frame.sessionPane.setForegroundAt(0,Color.blue); frame.sessionPane.setIconAt(0,focused);  }
   protected void closeSession(Session targetSession) {      int tabs = frame.sessionPane.getTabCount();      Sessions sessions = manager.getSessions();      Session session = null;      if (tabs > 1) {         if ((sessions.item(targetSession)) != null) {            int index = frame.sessionPane.indexOfComponent(targetSession);            System.out.println("session found and closing down " + index);            frame.sessionPane.remove(index);            manager.closeSession(targetSession);            targetSession = null;            if (index < (tabs - 2)) {               frame.sessionPane.setSelectedIndex(index);               frame.sessionPane.setForegroundAt(index,Color.blue);               frame.sessionPane.setIconAt(index,focused);            }            else {               frame.sessionPane.setSelectedIndex(0);               frame.sessionPane.setForegroundAt(0,Color.blue);               frame.sessionPane.setIconAt(0,focused);            }         }      }      else {         closingDown(frame);      }   }