scriptingTabPane.setSelectedIndex(0);
scriptingTabPane.setSelectedIndex(scriptingTabPane.getTabCount()-1); int tabIndex = tabPane.indexOfTab(scriptingPanelName); if (tabIndex >= 0){ tabPane.setSelectedIndex(tabIndex); }
   public static void addScriptingPanel (JTabbedPane tabPane, String sfObjName, Object sfObj, String hostname, int port) throws Exception {      JPanel scriptingPanel = new JPanel();      JTabbedPane scriptingTabPane = null;      try {        Class jConsoleClass = Class.forName("bsh.util.JConsole");        Class intepreterClass = Class.forName("bsh.Interpreter");        Class jConsoleInterface = Class.forName ("bsh.ConsoleInterface");        //Gets parameters for constructor if any        //Object[] jConsoleparameters = [""];        // get the right constructor method method        Constructor jConsoleConstructor = jConsoleClass.getConstructor(null);        Class[] classParameters = {jConsoleInterface};        Constructor interpreterConstructor = intepreterClass.getConstructor(classParameters);        // Invoke the constructors        Object jConsoleObject = jConsoleConstructor.newInstance(null);        Object[] parameters = {jConsoleObject};        Object interpreterObject = interpreterConstructor.newInstance(parameters);        // Invoke method set("prim",this);        //java.lang.String string, java.lang.Object object        classParameters = new Class[]{String.class, Object.class};        Method method = intepreterClass.getMethod("set",classParameters);        ProcessCompound rootProcess = SFProcess.getRootLocator().getRootProcessCompound(InetAddress.getByName(hostname), port);        method.invoke(interpreterObject, new Object[] {"bsh.system.shutdownOnExit",new Boolean(false)});          method.invoke(interpreterObject, new Object[]{"rootProcess",rootProcess});        method.invoke(interpreterObject, new Object[]{"localProcess",SFProcess.getProcessCompound()});        String panelName="";        if (sfObj!=null) {           method.invoke(interpreterObject, new Object[]{"sfObj",sfObj});           method.invoke(interpreterObject, new Object[]{sfObjName,sfObj});           panelName = sfObjName;        } else {            panelName = "rootProcess";        }        new Thread((Runnable) interpreterObject).start(); // start a thread to call the run() method        scriptingTabPane = initScriptingTabbedPane(tabPane,true);        scriptingTabPane.add((Component)jConsoleObject, panelName);        scriptingTabPane.setSelectedIndex(0);      } catch (Throwable thr){          if (sfLogStatic().isErrorEnabled()){ sfLogStatic().error(thr);}          WindowUtilities.showError(scriptingTabPane, thr.toString());      }   }