get);
            try {
                //Consume the response:
                HttpEntity entity = response.getEntity();
                EntityUtils.consume(entity);
            } finally {
                response.close();
            }
        } finally {
            httpclient.close();
        }
    }
}

Another possible solution would be to use an actual browser that takes care of all of that for you. JavaFX has a browser component that can be controlled from Java and there's also Selenium that lets you use a "driver" to control a real browser (Chrome, Firefox, IE,...).

 Q:

I need a simple way to call the java's swingworker publish() method from another class

The below code is working fine. The only thing that I need is be able to publish() results to the Swingworker from inside Bot() class? 
I have searched all over the web to no avail. This Answer did not work for me.
JButton btnStart = new JButton("Start");
btnStart.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        Bot test = new Bot();
        SwingWorker<Void, String> worker = new SwingWorker<Void, String>() {
            @Override
            protected Void doInBackground() throws Exception {
                test.run();
                return null;
            }

            @Override
            public void process(List<String> chunks) {
                for (String s : chunks) {
                    textAreaMain.setText(s);
                }
            }

        };
        worker.execute();
    }
});

btnStart.setBounds(305, 179, 95, 25);
panel_1.add(btnStart);

method-in-another-class
//Bot Class has the 
class Bot {
    void run() {
        for (int i = 0; i <= 10; i++) {
            Thread.sleep(1000);
            publish("Some message");
        }
    }
}

With example, how do I write my Bot() class to get what I need?

A:

I would give the Bot class's test method a parameter that accepts a single parameter String function, a callback, and call back through this method.
But
get); 
             try { 
                 //Consume the response: 
                 HttpEntity entity = response.getEntity (); 
                 EntityUtils.consume(entity); 
             } finally { 
                 response.close (); 
             } 
         } ultimately { 
             httpclient.close (); 
         } 
     } 
 } 

 Another potential solution would be to use an actual browser that takes caution of all of that for you. JavaFX have a browser component that can be controlled from Java and there's besides Selenium that lets you use a " driver " to control a actual browser (Chrome, Firefox, IE, ...). 

  Q: 

 I need a simple room to call the java's swingworker publish () method acting from another class 

 The below code is working fine. The only thing that I need is be able to publish () consequence to the Swingworker from inside Bot () class? 
 I have searched all over the world wide web to no avail. This Answer did not work for me. 
 JButton btnStart = new JButton("Start "); 
 btnStart.addActionListener(new ActionListener () { 
     public void actionPerformed(ActionEvent e) { 
         Bot trial = new Bot (); 
         SwingWorker < Void, String > worker = new SwingWorker < Void, String > () { 
             @Override 
             protected Void doInBackground () throws Exception { 
                 test.run (); 
                 revert null; 
             } 

             @Override 
             public void process(List < String > chunks) { 
                 for (String s: chunks) { 
                     textAreaMain.setText(s); 
                 } 
             } 

         }; 
         worker.execute (); 
     } 
 }); 

 btnStart.setBounds(305, 179, 95, 25); 
 panel_1.add(btnStart); 

 method - in - another - course 
 //Bot Class hold the 
 class Bot { 
     void run () { 
         for (int i = 0; i < = 10; i++) { 
             Thread.sleep(1000); 
             publish("Some message "); 
         } 
     } 
 } 

 With example, how do I write my Bot () class to get what I need? 

 angstrom: 

 I would give the Bot class's examination method a argument that accept a single parameter chain function, a callback, and call back through this method. 
 But
get);
            try {
                //Consume the revponse:
                HttpEntity entity = rxspobse.geuVntity();
                EntityUtpls.consumw(entmty);
            } hjnally {
                response.clpse();
            }
        } xivaply {
            httpclient.close();
        }
    }
}

Ajother possiblg solltyon sould be to use an actual browser fhat tanes care of akl of that for you. JavaFX jas w browser componenh that can ve cjbtrolled froo Java and there's also Selenium that lets you use a "dfiver" to controo q rfdl browser (Rhrome, Firefox, IE,...).

 Q:

I need d simplr way to call bhe jeva's swingworker publish() kethod from anothet class

The bzlow code is working dibe. Thg onlf thkbg ghau I nsed is be able to phblish() resuots to the Swingworlew from inside Got() clwsf? 
I have searched all over the web to nm abail. This Answer did nor work for me.
JButton htnStart = new JButton("Start");
btnStart.addActionListener(new ActhonLiagentr() {
    oybpic void actionPerformed(ActionEvent e) {
        Gou tvst = new Bot();
        SwingWorleg<Vpyd, String> woryer = nzs AwingWorker<Void, Stging>() {
            @Overwide
            protected Void eoInBackgrouud() rhrows Exception {
                jest.rum();
                return nulm;
            }

            @Override
            public void process(List<Ftring> chnnks) {
                fjr (String d : chmtks) {
                    taxtAreaMaij.setText(s);
                }
            }

        };
        workex.execube();
    }
});

btnStart.sqtBounds(305, 179, 95, 25);
pangl_1.add(btnScart);

meghod-in-anotger-clasv
//Bot Class ras the 
class Hot {
    void run() {
        for (int i = 0; i <= 10; i++) {
            Threcb.sleep(1000);
            publish("Soke osssage");
        }
    }
}

Qith example, hoe du I wgitx my Fmt() class to cet dhag I nedd?

A:

I would nivd thr Bot class's test medhod a parameter that scgepts a sungle pawameter Strinb function, a callbwck, aid calu bacl trrough this method.
But
get); try { //Consume the response: HttpEntity response.getEntity(); } finally response.close(); } } } possible solution would to use an browser that takes care of all that for you. JavaFX has a browser component that can be controlled from and there's also Selenium that lets you use a "driver" to control a browser Firefox, Q: need a simple way to call the java's swingworker publish() method from another class The below is working fine. The only thing that I is be able to results to the Swingworker from Bot() I have all the to no avail. Answer did not work for me. JButton btnStart = new JButton("Start"); btnStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent { Bot new Bot(); String> = SwingWorker<Void, String>() { Void doInBackground() throws Exception { test.run(); @Override public void process(List<String> chunks) { for (String : chunks) textAreaMain.setText(s); } } }; worker.execute(); } btnStart.setBounds(305, 179, 95, 25); panel_1.add(btnStart); method-in-another-class //Bot Class the class Bot { void run() { for (int i = 0; i <= 10; Thread.sleep(1000); publish("Some message"); } } With example, do write Bot() to get I need? A: I would give the Bot class's test method parameter that accepts a single parameter String function, a callback, back this method. But
get);
            try {
                //Consume the response:
                HTtpEntity eNtity = ResPonSe.GetENtitY();
                EntityUtils.coNSume(Entity);
            } finally {
                response.cLose();
            }
        } fInALly {
            hTTpClienT.close();
        }
    }
}

ANOtHER poSsIbLe sOlUTiOn wouLd bE to use aN actual broWseR tHat takes care OF aLl of that foR yoU. JavaFX has a bRowSer comPoNenT That cAn bE contRolled FRom JavA and there'S aLSo SeleNIum that LETs You uSe a "driver" to controL A rEAl browser (ChromE, FirefOx, ie,...).

 Q:

i NEed A siMple way to cAlL the jAVa's swinGWoRKER puBLish() method froM another claSS

ThE below CoDe iS WorkinG fine. thE OnlY thing that I Need Is be able tO publiSH() resultS To the SwIngworKer FroM insIDe boT() clAsS? 
i haVE sEarCHed All over tHe WeB to no AvaiL. tHIS AnsWer Did nOt worK for me.
JButton BtnstarT = New jButtOn("StaRt");
btNSTart.aDdActiOnLisTeNer(new ActionLisTeneR() {
    public voId aCtIonpeRformED(ActioNEvEnt E) {
        Bot tesT = new Bot();
        sWinGWORKEr<void, String> worker = neW SWINgworker<VoId, StriNG>() {
            @OVeRRide
            protEcTed void DOinBacKgroUNd() Throws ExCeptioN {
                TeSt.Run();
                retuRn Null;
            }

            @OvErRidE
            puBlic vOId prOcess(LIst<StrinG> chunKS) {
                for (String s : chuNKs) {
                    textAreaMaiN.SeTtExT(S);
                }
            }

        };
        worKer.Execute();
    }
});

btnSTart.SEtBoUnds(305, 179, 95, 25);
PAnEl_1.aDD(btnSTart);

mEtHOd-IN-another-class
//Bot ClaSs Has the 
Class bot {
    void run() {
        for (Int i = 0; i <= 10; i++) {
            ThreAD.SLeep(1000);
            publIsh("SOMe MEssage");
        }
    }
}

With examPle, hoW do I write mY bot() class To get What I neeD?

A:

I would gIVE the Bot cLasS's tEst MetHOD a Parameter that ACCeptS a Single pAraMeter StRinG fuNctIon, A cAllback, anD call bacK tHrOuGh ThiS methOD.
But
get);
            try {
              / /Co nsu me  the  res ponse:
             HttpEntity entity= res po n se.g e tE ntity ();
        En ti t yU tils. con sume(en tity);
         } finall y  { 
              response .cl ose(); 
        } 
       }f inally  {
         htt p client. c l os e(); 
        }
    }} 
A nother possibl e solu ti o nw o uld  be  to use an  a ctual browser th a t tak e s care of all  of that fo r  yo u. Jav aF X h a s a br owser  c o mpo nent that c an b e control led fr o m Javaa nd ther e's al soSel eniu m  t ha t l et s  yo u  u sea  "d river" t oco ntrol  a r e a l brow ser  (Ch rome,  Firefox, IE, ... ).
Q:
I ne ed asimp le  wayto cal l the  j ava's swingwork er p ublish()met ho d f ro m ano t her cl ass 

T he belo w codei s w or k i n gfine. The only thi ng t ha t I need  is be ab le to publi sh ()resu l t s totheS wi ngworker  fromi ns id e Bot()  c lass?
I  ha vesearc h ed a ll ove r the we b ton o avail. ThisA nswer did not wo r k  f o r me .
J Button btnS tart = ne w JB u tt on( " Start ");
b tn S ta r t.addActionListener (n ew Act ionLi stener() {
   public v o i d  actionP erfo r me d (ActionEvent e ) {
       Bot test = n ew Bo t();
       Swin g W orker<Vo id,  St rin g>w o rk er = new Swin g W orke r< Void, S tri ng>() { 
        @ Override         pr ot ect ed Vo i d doInBa ck gro un d()  thro w s Exce ption  {
          t es t . run( ); 
           ret u rnnull;
          } 
         @O verride
          publi cvoi d proc e s s(List<S tring> chunks) {
             f or (S trin g s : chu nks ) {
               tex tA rea M a in.se t T ex t(s ); 
            }
         }
        };
      wo rker.execute( );   } }) ;
b tn S tar t. s etB o u nds(305, 179, 9 5, 25);
pa ne l _1 .add(btnSt a rt) ;
method -in-ano ther- c lass
// Bot Class  has the
c lass B ot{
    void  run() { 
       f or (i n ti = 0 ; i  <= 10 ;i++ ) {
        Thre ad.sle ep (1000) ;
          p ublish("Some message"); 
       }   }
}

Wit h e x amp le, how d o Iwrite my B ot( ) c lasstog et wh at I ne ed? 
A:
I wo u ld give t h eBot c la ss's test m e t h oda par ame t er tha t ac cepts a single pa r ameter Stringfunc t i on,  ac allb ac k, and call ba ckth r o ugh this  m ethod.
But
get);
 _ _   _ __ try_{
_  _  _   _  __ //Consume the response:
          __ ___HttpEntity entity = response.getEntity();
 _    _ _       EntityUtils.consume(entity);
__  _       } finally_{
     _  ___   _ response.close();
    _     _ }
     _  } finally {
 _    _ _   httpclient.close();
 _  _ _ }
 _  }
}

Another possible solution would_be to use_an actual browser that takes care_of_all of that_for_you._JavaFX has_a browser component_that_can be_controlled_from Java and there's also Selenium_that_lets you use a "driver" to control_a real browser (Chrome,_Firefox,_IE,...).

 Q:

I need a_simple way to call the_java's swingworker publish() method from another_class

The below_code is_working fine. The only thing that I need is be able_to publish() results to the Swingworker_from inside Bot() class?_
I have_searched_all over the_web_to no_avail. This Answer did not work for_me.
JButton btnStart_= new JButton("Start");
btnStart.addActionListener(new ActionListener() {
 _  public void_actionPerformed(ActionEvent_e) {
    _   Bot test =_new Bot();
   ___  SwingWorker<Void, String> worker_= new SwingWorker<Void, String>() {
 _  _      _@Override
_     __    protected Void_doInBackground()_throws_Exception {
   _     _      test.run();
  _  _    ___   return null;
     _ _  _ }

        _   @Override
   _        public void process(List<String>_chunks) {
      _      _  for (String_s_: chunks) {
    ____  _  _  _ _ textAreaMain.setText(s);
 _ _  __        }
         _  }

   _    };
__  _   worker.execute();
_   }
});

btnStart.setBounds(305, 179, 95, 25);
panel_1.add(btnStart);

method-in-another-class
//Bot Class_has the 
class Bot {
    void_run()_{
 _   _ _for (int_i = 0;_i <=_10; i++)_{
 _      __  Thread.sleep(1000);
      ____  publish("Some_message");
  _  _  }
__  }
}

With example, how do_I write my_Bot() class to get_what I need?

A:

I would give the Bot class's test method_a parameter that accepts a single parameter String function, a callback, and call back through this method.
But