if (index < tabs) { sessionPane.setSelectedIndex(index); sessionPane.setForegroundAt(index,Color.blue); sessionPane.setIconAt(index,focused); ((Session)sessionPane.getComponentAt(index)).requestFocus();
if (getContentPane().getComponent(x) instanceof Session) { getContentPane().remove(x); } }
   public void removeSessionView(Session targetSession) {      int index = sessionPane.indexOfComponent(targetSession);      System.out.println("session found and closing down " + index);      targetSession.removeSessionListener(this);      targetSession.removeSessionJumpListener(this);      int tabs = sessionPane.getTabCount();      sessionPane.remove(index);      tabs--;      if (index < tabs) {         sessionPane.setSelectedIndex(index);         sessionPane.setForegroundAt(index,Color.blue);         sessionPane.setIconAt(index,focused);         ((Session)sessionPane.getComponentAt(index)).requestFocus();      }      else {         if (tabs > 0) {            sessionPane.setSelectedIndex(0);            sessionPane.setForegroundAt(0,Color.blue);            sessionPane.setIconAt(0,focused);            ((Session)sessionPane.getComponentAt(0)).requestFocus();         }      }   }