Tema: Re: J2ME
Autorius: Auris
Data: 2010-03-03 16:59:31
kadangi nezinau j2me specific dalyku, pameginau pamodeliuot situacija ant 
plain java. Juk pagrindas tame.
Galbut net yra kazkoks design patternas tokiam dalykui.

"Tadas B." <nera@mailo.com> wrote in message 
news:op.u8zslkdsd7giwi@pz-tadbra.kdomain.pienozvaigzdes.lt...
>  aaa o cia tikrai buvo atsakymas apie Java Micro Edition? :)
>  Gavau sprendima per listener'i, taigi aciu, problemos nebera
>
>
> On Wed, 03 Mar 2010 11:53:38 +0200, Auris <Paciukas@gmail.com> wrote:
>
>> Pateikiu analogiska pavyzdi ir galima sprendima. Sprendimo esme perduoti 
>> i
>> Calculator save. Bet gali toks sprendimas ir neveikti, jei  kokia nors
>> desktopines aplikacijos  langas pradedamas keisti kitame thread'e. Kitas
>> solutionas butu perduoti kazkoki tai listeneri, o pagrindine klase kaz
>> kazkiek laiko tikrintu sita listneri ar pasikeite koks flagas.
>>
>> public class MainRun extends Thread {
>>
>>
>> public static void main(String[] args) {
>>     MainRun a = new MainRun();
>>     a.startButton();
>>     a.start();
>> }
>>
>>
>> public void startButton() {
>>     System.out.println("Start");
>> }
>>
>>
>> public void stopButton() {
>>     System.out.print("Stop");
>> }
>>
>>
>>
>> public void run() {
>>       new Calculator().calculate(this);
>> }
>>
>>
>> }
>>
>>
>>
>> public class Calculator {
>>     public void calculate(MainRun mainRun) {
>>         try {
>>             Thread.sleep(10000);
>>             mainRun.stopButton();
>>         } catch (InterruptedException e) {
>>                 // TODO Auto-generated catch block
>>                 e.printStackTrace();
>>          }
>>     }
>> }
>>
>>
>>
>> "Tadas B." <nera@mailo.com> wrote in message
>> news:op.u8zdgmkod7giwi@pz-tadbra.kdomain.pienozvaigzdes.lt...
>>>   sveiki,
>>>
>>>  Gal galite kas paprotinti, kaip isspresti toki reikala:
>>> Turiu MIDlet'a, kuriame yra vizualizacija, t.y. mygtukai, rezultatai ir
>>> panasiai. Kitame package ir aisku kitoje klaseje (tarkim CLASS2) turiu
>>> metodus, kurie daro tam tikrus veiksmus. Is MIDlet'o paleidziu komanda
>>> "Start", kuri paleidzia  CLASS2.calculate() metoda. MIDlet'e pasalinu
>>> komanda Start ir pridedu komanda Stop (rankiniam proceso stabdymui). As
>>> nemoku, kaip padaryti, kad kai calculate() metodas baigia darba MIDlet'e
>>> pasalintu Stop komanda ir grazintu Start. Kam geriau skaitosi is kodo,
>>> pridedu zemiau pvz. Kodel isskiriu vizualizacija ir action'a
>>> neklausinekite - taip reikia, jei tureciau viska MIDlet'e klausimu
>>> nebutu:)
>>>
>>>
>>> MIDlet:
>>>
>>> public class HelloMIDlet extends MIDlet implements CommandListener,
>>> ItemCommandListener {
>>> private Command screenCommandstart;
>>> private Command screenCommandstop;
>>> ....
>>> public void commandAction(Command command, Displayable displayable){
>>> if (displayable == form) {
>>>        if (command == screenCommandstart) {
>>>                 form.removeCommand(getScreenCommandstart());
>>>                 form.addCommand(getScreenCommandstop());
>>>                 new metodas().Start();
>>>             } else if (command == screenCommandstop) {
>>>                 form.removeCommand(getScreenCommandstop());
>>>                 form.addCommand(getScreenCommandstart());
>>>             }
>>>         }
>>>     }
>>> ----------
>>> CLASS2:
>>>
>>> public class CLASS2 {
>>>
>>>     public void calculate(){
>>>          try {
>>>                     //do something
>>>                 } catch (InterruptedException e) {
>>>                 }
>>>          //cia realiai reiktu paleisti commandAction(screenCommandstop,
>>> form) MIDlet'e
>>>
>>>     }
>>>
>>> --
>>> Tadas B.
>>
>>
>
>
> -- 
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/