Sunday, November 23, 2008

In How Many Units Does Heparin

THE REST OF THE INTERFACE

two deliveries in the latter one, we seen the use of two components to the use of menus, we saw the kind LIST and CHOICEGROUP , we found that basically the difference between the two is that the class LIST is not subordinate to the class FORM , that is, it is not necessary to first create an object type FORM then add the object LIST.



private Display display;

private mylist;

...

display = Display.getDisplay (this);

mylist = new List ("Options" List.IMPLICIT)
miLista.append ("High", null);
miLista.append ( low ", null);
miLista.append (" Query ", null);
miLista.append (" Amendments ", null);
miLista.append (" Print ", null);
...


display.setCurrent (mylist);



CHOICEGROUP While an object must be attached to a Form.



private Display miDisplay;
Form miForma private, private
ChoiceGroup myGroup;


...

miDisplay = Display.getDisplay (this);
miForma = new Form ("MAIN MENU");


...

ChoiceGroup myGroup = new ("Options:" ChoiceGroup.EXCLUSIVE)
miGrupo.append ("High", null);
miGrupo.append ("Low", null);
miGrupo.append ( "Consultations", null);
miGrupo.append ("Amendments", null);
miGrupo.append ("Print", null);


...

miForma.append (myGroup)

...
display.setCurrent (mylist);




But besides these classes we have many more like ...


Class Ticker

Util to display messages in the form of a canopy gliding side to side of the user's screen.


Class DateField

Useful for handling dates, either for display or to request the user to provide a specific date.



Class ImageItem

Useful for work with image files in your application. We shall see later, but with this tool you can add a visual appeal that makes it more friendly and user friendly.


Class TextField

Useful for text handling, which can be deployed alone or, to ask the user to enter data. Such as password, numbers, names, etc.



should be noted that high-level graphics classes, have the facility to suit the type of deployment available to the device in which we work.

In other words, we call the classes and create the objects in our application, but the display is under the control of the hardware.



Let's see, the use of the classes mentioned above, in one example.


import java.io.IOException;
import java.util.Date;
javax.microedition.lcdui.Command import, import
javax.microedition.lcdui.CommandListener;
javax.microedition.lcdui.DateField import;
javax.microedition.lcdui.Display import, import
javax.microedition.lcdui.Displayable;

import javax.microedition.lcdui.Form;

import javax.microedition.lcdui.Image;

import javax.microedition.lcdui.ImageItem;

import javax.microedition.lcdui.Item;

import javax.microedition.lcdui.ItemStateListener;

import javax.microedition.lcdui.TextField;

import javax.microedition.lcdui.Ticker;

import javax.microedition.midlet.MIDlet;

import javax.microedition.midlet.MIDletStateChangeException;






public class MIDOtros extends MIDlet implements CommandListener, ItemStateListener {

private Ticker miMarquesina;

private DateField miFecha;

private ImageItem miImagen;

private TextField miHumor;

private Image imgSerio, imgFeliz, imgTriste;

private Command Salir;

private Display miDisplay;

private Form miForma;





public MIDOtros() {

try {

imgSerio = Image.createImage("/serio.PNG");

imgFeliz = Image.createImage("/feliz.PNG");

imgTriste = Image.createImage("/triste.PNG");

} catch (IOException e) {

e.printStackTrace();

}





Date wHoy = new Date();

miDisplay = Display.getDisplay(this);

miFecha = new DateField("Dia de hoy",DateField.DATE);

miFecha.setDate(wHoy);

miHumor = new TextField("% de Animo", "50", 2, TextField.NUMERIC);

miMarquesina = new Ticker("Ejemplo de Graficos de Alto Nivel. Tutorial para el Desarrollo de aplicaciones en móviles, País México. Noviembre del 2008");

miForma = new Form("Otros Items");

Salir = new Command("Salir", Command.EXIT, 0);

miImagen = new ImageItem(null, imgSerio, 0, null);

miForma.setTicker(miMarquesina);

miForma.append(miFecha);

miForma.append(miImagen);

miForma.append(miHumor);

miForma.addCommand(Salir);

miForma.setCommandListener(this);

miForma.setItemStateListener(this);

}





protected void destroyApp(boolean arg0) throws MIDletStateChangeException {

}





protected void pauseApp() {

}





protected void startApp() throws MIDletStateChangeException {

this.miDisplay.setCurrent(this.miForma);

}





public void commandAction(Command arg0, Displayable arg1) {

if (arg0 == Salir){

try {

destroyApp(false);

} catch (MIDletStateChangeException e) {

e.printStackTrace();

}
notifyDestroyed ();

}} public void


itemStateChanged (Item arg0) {
if (arg0 == miHumor) {int
wValor = Integer.parseInt (miHumor.getString ());
if (wValor <> 70) {
miImagen.setImage (imgFeliz)} else {

miImagen.setImage (imgSerio)

}}}


}}




As noted, in this application handle image files:


imgSerio = Image.createImage ("/ serio.PNG");
imgFeliz = Image.createImage ("/ feliz.PNG");
imgTriste = Image.createImage ("/ triste.PNG");




What are PNG files, this allows us to handle images with a good reasonable resolution and store in a small space.
Well, once compiled our code, we can run it and see it in action.

0 comments:

Post a Comment