Example #1
0
 public void addBot() {
   if (bots.size() > MAX_BOTS) {
     return;
   }
   final Bot bot = new Bot();
   bots.add(bot);
   toolBar.addTab();
   toolBar.setAddTabVisible(bots.size() < MAX_BOTS);
   bot.getScriptHandler().addScriptListener(this);
   new Thread(
           new Runnable() {
             public void run() {
               bot.start();
             }
           })
       .start();
 }
Example #2
0
 public void removeBot(final Bot bot) {
   final int idx = bots.indexOf(bot);
   bot.getScriptHandler().stopAllScripts();
   bot.getScriptHandler().removeScriptListener(this);
   if (idx >= 0) {
     toolBar.removeTab(idx);
   }
   bots.remove(idx);
   toolBar.setAddTabVisible(bots.size() < MAX_BOTS);
   new Thread(
           new Runnable() {
             public void run() {
               bot.stop();
               System.gc();
             }
           })
       .start();
 }