Flow Design [RESOLVIDO!]

0 respostas
Rafael_Brito

segue o código, e uma figura ao final do código....
gostaria de saber como faço para relacionar um itemChoice com uma tela, como no anexo que segue. Onde as linhas vermelhas são cada uma das telas, de acordo com a opção do usuário.
Soh estou conseguindo que o usuário tenha uma única opção, como se ele naum tivesse as demais opções, itemChoice.

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Tutorial extends MIDlet implements CommandListener {    
    
    public Tutorial() {
        initialize();
    }
    
    private Form form1;                     
    private Command exitCommand1;
    private Command screenCommand1;
    private ChoiceGroup choiceGroup1;
    private Form form2;
    private ChoiceGroup choiceGroup2;
    private Form form3;
    private ChoiceGroup choiceGroup3;
    private Command screenCommand2;
    private Command backCommand1;
    private TextBox textBox1;
    private Command backCommand2;
    private TextBox textBox2;
    private Command backCommand3;                   
    
                     

    /** Called by the system to indicate that a command has been invoked on a particular displayable.                      
     * @param command the Command that ws invoked
     * @param displayable the Displayable on which the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {                    
    // Insert global pre-action code here
        if (displayable == form1) {                     
            if (command == screenCommand1) {                   
                // Insert pre-action code here
                getDisplay().setCurrent(get_form2());                       
                // Insert post-action code here
            } else if (command == exitCommand1) {                     
                // Insert pre-action code here
                exitMIDlet();                       
                // Insert post-action code here
            }                      
        } else if (displayable == form2) {
            if (command == backCommand1) {                    
                // Insert pre-action code here
                getDisplay().setCurrent(get_form1());                        
                // Insert post-action code here
            } else if (command == screenCommand2) {                      
                // Insert pre-action code here
                getDisplay().setCurrent(get_textBox1());                        
                // Insert post-action code here
            }                       
        } else if (displayable == textBox1) {
            if (command == backCommand2) {                     
                // Insert pre-action code here
                getDisplay().setCurrent(get_form2());                        
                // Insert post-action code here
            }                       
        } else if (displayable == textBox2) {
            if (command == backCommand3) {                     
                // Insert pre-action code here
                getDisplay().setCurrent(get_form2());                        
                // Insert post-action code here
            }                       
        }                     
    // Insert global post-action code here
}                   

    /** This method initializes UI of the application.                        
     */
    private void initialize() {                      
        // Insert pre-init code here
        getDisplay().setCurrent(get_form1());                      
        // Insert post-init code here
    }                     
    
    /**
     * This method should return an instance of the display.
     */
    public Display getDisplay() {                         
        return Display.getDisplay(this);
    }                        
    
    /**
     * This method should exit the midlet.
     */
    public void exitMIDlet() {                         
        getDisplay().setCurrent(null);
        destroyApp(true);
        notifyDestroyed();
    }                        

    /** This method returns instance for form1 component and should be called instead of accessing form1 field directly.                        
     * @return Instance for form1 component
     */
    public Form get_form1() {
        if (form1 == null) {                      
            // Insert pre-init code here
            form1 = new Form("Tutorial", new Item[] {get_choiceGroup1()});                       
            form1.addCommand(get_exitCommand1());
            form1.addCommand(get_screenCommand1());
            form1.setCommandListener(this);                     
            // Insert post-init code here
        }                      
        return form1;
    }                    

    /** This method returns instance for exitCommand1 component and should be called instead of accessing exitCommand1 field directly.                        
     * @return Instance for exitCommand1 component
     */
    public Command get_exitCommand1() {
        if (exitCommand1 == null) {                      
            // Insert pre-init code here
            exitCommand1 = new Command("Sair", Command.EXIT, 1);                      
            // Insert post-init code here
        }                      
        return exitCommand1;
    }                    

    /** This method returns instance for screenCommand1 component and should be called instead of accessing screenCommand1 field directly.                        
     * @return Instance for screenCommand1 component
     */
    public Command get_screenCommand1() {
        if (screenCommand1 == null) {                      
            // Insert pre-init code here
            screenCommand1 = new Command("Selecione", Command.SCREEN, 1);                      
            // Insert post-init code here
        }                      
        return screenCommand1;
    }                    

    /** This method returns instance for choiceGroup1 component and should be called instead of accessing choiceGroup1 field directly.                        
     * @return Instance for choiceGroup1 component
     */
    public ChoiceGroup get_choiceGroup1() {
        if (choiceGroup1 == null) {                      
            // Insert pre-init code here
            choiceGroup1 = new ChoiceGroup("Selecao", Choice.EXCLUSIVE, new String[] {                       
                "Definicoes",
                "Exemplos"
            }, new Image[] {
                null,
                null
            });
            choiceGroup1.setSelectedFlags(new boolean[] {
                false,
                false
            });                     
            // Insert post-init code here
        }                      
        return choiceGroup1;
    }                    

    /** This method returns instance for form2 component and should be called instead of accessing form2 field directly.                         
     * @return Instance for form2 component
     */
    public Form get_form2() {
        if (form2 == null) {                       
            // Insert pre-init code here
            form2 = new Form("Tutorial", new Item[] {get_choiceGroup2()});                        
            form2.addCommand(get_screenCommand2());
            form2.addCommand(get_backCommand1());
            form2.setCommandListener(this);                      
            // Insert post-init code here
        }                       
        return form2;
    }                     

    /** This method returns instance for choiceGroup2 component and should be called instead of accessing choiceGroup2 field directly.                         
     * @return Instance for choiceGroup2 component
     */
    public ChoiceGroup get_choiceGroup2() {
        if (choiceGroup2 == null) {                       
            // Insert pre-init code here
            choiceGroup2 = new ChoiceGroup("Definicao", Choice.EXCLUSIVE, new String[] {                        
                "J2ME",
                "KVM",
                "API",
                "CLDC",
                "MIDP",
                "MIDlet",
                "Tratamento de Eventos"
            }, new Image[] {
                null,
                null,
                null,
                null,
                null,
                null,
                null
            });
            choiceGroup2.setSelectedFlags(new boolean[] {
                false,
                false,
                false,
                false,
                false,
                false,
                false
            });                      
            // Insert post-init code here
        }                       
        return choiceGroup2;
    }                     

    /** This method returns instance for form3 component and should be called instead of accessing form3 field directly.                         
     * @return Instance for form3 component
     */
    public Form get_form3() {
        if (form3 == null) {                       
            // Insert pre-init code here
            form3 = new Form("Tutorial", new Item[] {get_choiceGroup3()});                       
            // Insert post-init code here
        }                       
        return form3;
    }                     

    /** This method returns instance for choiceGroup3 component and should be called instead of accessing choiceGroup3 field directly.                         
     * @return Instance for choiceGroup3 component
     */
    public ChoiceGroup get_choiceGroup3() {
        if (choiceGroup3 == null) {                       
            // Insert pre-init code here
            choiceGroup3 = new ChoiceGroup("Exemplos", Choice.EXCLUSIVE, new String[] {                        
                "Choice Element",
                "Choice Element",
                "Choice Element",
                "Choice Element"
            }, new Image[] {
                null,
                null,
                null,
                null
            });
            choiceGroup3.setSelectedFlags(new boolean[] {
                false,
                false,
                false,
                false
            });                      
            // Insert post-init code here
        }                       
        return choiceGroup3;
    }                     

    /** This method returns instance for screenCommand2 component and should be called instead of accessing screenCommand2 field directly.                         
     * @return Instance for screenCommand2 component
     */
    public Command get_screenCommand2() {
        if (screenCommand2 == null) {                       
            // Insert pre-init code here
            screenCommand2 = new Command("Selecione", Command.SCREEN, 1);                       
            // Insert post-init code here
        }                       
        return screenCommand2;
    }                     

    /** This method returns instance for backCommand1 component and should be called instead of accessing backCommand1 field directly.                         
     * @return Instance for backCommand1 component
     */
    public Command get_backCommand1() {
        if (backCommand1 == null) {                       
            // Insert pre-init code here
            backCommand1 = new Command("Voltar", Command.BACK, 1);                       
            // Insert post-init code here
        }                       
        return backCommand1;
    }                     

    /** This method returns instance for textBox1 component and should be called instead of accessing textBox1 field directly.                         
     * @return Instance for textBox1 component
     */
    public TextBox get_textBox1() {
        if (textBox1 == null) {                       
            // Insert pre-init code here
            textBox1 = new TextBox("J2ME", "J2ME eh uma linguagem de Programacao.", 120, TextField.ANY);                        
            textBox1.addCommand(get_backCommand2());
            textBox1.setCommandListener(this);                      
            // Insert post-init code here
        }                       
        return textBox1;
    }                     

    /** This method returns instance for backCommand2 component and should be called instead of accessing backCommand2 field directly.                         
     * @return Instance for backCommand2 component
     */
    public Command get_backCommand2() {
        if (backCommand2 == null) {                       
            // Insert pre-init code here
            backCommand2 = new Command("Voltar", Command.BACK, 1);                       
            // Insert post-init code here
        }                       
        return backCommand2;
    }                     

    /** This method returns instance for textBox2 component and should be called instead of accessing textBox2 field directly.                         
     * @return Instance for textBox2 component
     */
    public TextBox get_textBox2() {
        if (textBox2 == null) {                       
            // Insert pre-init code here
            textBox2 = new TextBox("KVM", "KVM eh a maquina virtual Java.", 120, TextField.ANY);                        
            textBox2.addCommand(get_backCommand3());
            textBox2.setCommandListener(this);                      
            // Insert post-init code here
        }                       
        return textBox2;
    }                     

    /** This method returns instance for backCommand3 component and should be called instead of accessing backCommand3 field directly.                         
     * @return Instance for backCommand3 component
     */
    public Command get_backCommand3() {
        if (backCommand3 == null) {                       
            // Insert pre-init code here
            backCommand3 = new Command("Voltar", Command.BACK, 1);                       
            // Insert post-init code here
        }                       
        return backCommand3;
    }                     
    
    public void startApp() {
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
    }
    
}
Criado 11 de junho de 2007
Respostas 0
Participantes 1