final int index = desktop.getIndexOf(ses);
final int index = getIndexOfSession(ses);
   public void onSessionChanged(SessionChangeEvent changeEvent) {      Session ses = (Session)changeEvent.getSource();      switch (changeEvent.getState()) {         case STATE_CONNECTED:            final String d = ses.getAllocDeviceName();            if (d != null) {               System.out.println(changeEvent.getState() + " " + d);               final int index = desktop.getIndexOf(ses);               Runnable tc = new Runnable () {                  public void run() {                     JInternalFrame[] frames = desktop.getAllFrames();                     frames[index].setTitle(d);                  }               };               SwingUtilities.invokeLater(tc);            }            break;      }   }