import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class DemoMed extends MIDlet implements CommandListener
{
	private Display dsTela;
	private TextField tfNome,
	                  tfNasc,
					  tfIdade,
					  tfPat1,
					  tfPat2,
					  tfComment;
	private ChoiceGroup cgSexo,
	                    cgPat1,
						cgPat2;
	private Form	fmPrincipal;
	private Command cmSalva, cmSair;
	
	public DemoMed()
	{
		//INSTANCIA DA TELA
		dsTela = Display.getDisplay(this);
				
		cgSexo 		= new ChoiceGroup("Sexo", Choice.EXCLUSIVE);
		cgSexo.append("Masc", null);
		cgSexo.append("Fem", null);
		
		cgPat1		= new ChoiceGroup("", Choice.EXCLUSIVE);
		cgPat1.append("H", null);
		cgPat1.append("D", null);
		
		cgPat2		= new ChoiceGroup("", Choice.EXCLUSIVE);
		cgPat1.append("H", null);
		cgPat1.append("D", null);
		
		tfNome 		= new TextField("Nome:", "", 15, TextField.ANY);
		tfNasc	 	= new TextField("Nascimento:", "", 10, TextField.ANY);
		tfIdade	 	= new TextField("Idade:", "", 3, TextField.ANY);
		tfPat1		= new TextField("Patologia 1:", "", 25, TextField.ANY);
		tfPat2		= new TextField("Patologia 2:", "", 25, TextField.ANY);
		tfComment	= new TextField("Comentarios:", "", 100, TextField.ANY);
		
		cmSalva		= new Command("Salvar", Command.SCREEN, 1);
		cmSair	= new Command("Cancelar", Command.EXIT, 2);
		
		//INSTANCIA DOS FORMS
		fmPrincipal 	= new Form("PROTOTIPO- UNIP");
		fmPrincipal.addCommand(cmSalva);
		fmPrincipal.addCommand(cmSair);
		fmPrincipal.append(tfNome);
		fmPrincipal.append(tfIdade);
		fmPrincipal.append(tfPat1);
		fmPrincipal.append(cgPat1);
		fmPrincipal.append(tfPat2);
		fmPrincipal.append(cgPat2);
		fmPrincipal.setCommandListener(this);
	}

		public void startApp()
		{
			dsTela.setCurrent(fmPrincipal);
		}
		
		public void pauseApp() {} // <-
	
		public void destroyApp(boolean unconditional) {} // <-
		
		public void commandAction(Command c, Displayable s)
		{
			if (c == cmSalva)
			{
				tfNome.setString("Funcionou!");
			}
			else if (c == cmSair)
			{
				destroyApp(false);
				notifyDestroyed();
			}
			
	    } //Note esse cara aki!!!!
		
}
	


