Probleme pour afficher une appl J2ME

Résolu/Fermé
kakashi05 Messages postés 186 Date d'inscription jeudi 28 juin 2007 Statut Membre Dernière intervention 12 août 2011 - 21 déc. 2008 à 16:49
kakashi05 Messages postés 186 Date d'inscription jeudi 28 juin 2007 Statut Membre Dernière intervention 12 août 2011 - 21 déc. 2008 à 17:03
Bonjour,
je suis entrain d'apprendre du J2ME donc j'essai de faire une peite application qui va se presenter sous forme de formulaire ou j'aurai des champs à remplir et des cases à coché donc mon probleme est la suivant j'arrive pas afficher en meme temps le formulaire et les cases à cocher je vous montre mon code si quelqu'un a une idee


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

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

/**
 * @author
 */
public class Telephone1 extends MIDlet implements CommandListener{
    
    private Display display;
    private TextField login, password;
    private Form form;
    private Command commandexit,commandok;
    private List list;
    String fruit[]={"Mango","Orange","Tomato"};
    
public Telephone1(){
    
  display=Display.getDisplay(this);
  
 //Affichage du message Bienvenu dans la barre des titres
    form =new Form("Bienvenu dans ce programme");
    
    //Creation du champ login avec une taille maxi de 30 caracteres
    login=new TextField("Login","", 30, TextField.ANY);
    
    //Creation du champ password avec une taille maxi de 30 caracteres et crypté
    password= new TextField("Password", "", 30,TextField.PASSWORD);
    
    //liste des produits 
    list =new List("Liste de fruit", Choice.EXCLUSIVE,fruit,null);
    
    
     //creation d'un bouton Ok pour valider le programme
    
    commandok= new Command("Ok", Command.OK,1);
    
    //creation d'un bouton Exit pour sortir du programme
    
    commandexit= new Command("Exit", Command.EXIT,2);
    
    //ici on fait appel au diferent fonction
    form.append(login);
    form.append(password);
    
    form.addCommand(commandok);
    form.addCommand(commandexit);
    
    //paramettre tres important s'il n'est pas present les bontons ne
    //marcheront pas
    form.setCommandListener(this);
 
}
    
    public void startApp() throws MIDletStateChangeException {
        display.setCurrent(form);
     
    }

    public void pauseApp() {
     
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable s) {
       
         //si on clique sur le bouton Exit
        if(c == commandexit){
        
            //appel manuel à la fermeture
            destroyApp(false);
            //on demande au manager de refermer l'application
            notifyDestroyed();
            
       
        }
        
    }

}

1 réponse

kakashi05 Messages postés 186 Date d'inscription jeudi 28 juin 2007 Statut Membre Dernière intervention 12 août 2011 32
21 déc. 2008 à 17:03
Probleme resolu
voila le nouveau code

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

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

/**
 * @author Sangare
 */
public class Telephone1 extends MIDlet implements CommandListener{
    
    private Display display;
    private TextField login, password;
    private Form form;
    private Command commandexit,commandok;
    private List list;
    private ChoiceGroup cg;
   
    
public Telephone1(){
    
  display=Display.getDisplay(this);
  
 //Affichage du message Bienvenu dans la barre des titres
    form =new Form("Bienvenu dans ce programme");
    
    //Creation du champ login avec une taille maxi de 30 caracteres
    login=new TextField("Login","", 30, TextField.ANY);
    
    //Creation du champ password avec une taille maxi de 30 caracteres et crypté
    password= new TextField("Password", "", 30,TextField.PASSWORD);
    
    //Creation de la zone avec la possibilité de selectionner un seul fruit
    cg= new ChoiceGroup("Choisiez votre fruit",Choice.EXCLUSIVE,new String [] {"Mango","Orange","Tomato"},null );
    
     //creation d'un bouton Ok pour valider le programme
    
    commandok= new Command("Ok", Command.OK,1);
    
    //creation d'un bouton Exit pour sortir du programme
    
    commandexit= new Command("Exit", Command.EXIT,2);
    
    //ici on fait appel au diferent fonction
    form.append(login);
    form.append(password);
    
    form.addCommand(commandok);
    form.addCommand(commandexit);
    
    //ici on va faire appel à la liste de fruit
    form.append(cg);
    
    //paramettre tres important s'il n'est pas present les bontons ne
    //marcheront pas
    form.setCommandListener(this);
 
}
    
    public void startApp() throws MIDletStateChangeException {
        display.setCurrent(form);
     
    }

    public void pauseApp() {
     
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable s) {
       
         //si on clique sur le bouton Exit
        if(c == commandexit){
        
            //appel manuel à la fermeture
            destroyApp(false);
            //on demande au manager de refermer l'application
            notifyDestroyed();
            
       
        }
        
    }

}
0