SlideShare a Scribd company logo
MIDP	
  GUI	
  Development:	
  	
  
 Alert,	
  List,	
  Form,	
  TextBox	
  

             Jussi	
  Pohjolainen	
  
Tampere	
  University	
  of	
  Applied	
  Sciences	
  
Displayable	
  Class	
  Hierarchy	
  
javax.microedi-on.lcdui	
                                            javax.microedi-on.lcdui.game	
  




                           Displayable	
                Canvas	
             GameCanvas	
  



                                  Screen	
  




          Alert	
      List	
           Form	
     TextBox	
  
TextBox	
  
•  To	
  get	
  the	
  user	
  input	
  

•  TextBox a = new TextBox(String
   title, String text, int maxSize,
   int constraints)
Types	
  and	
  Flags	
  
•  Types	
                       •  Flags	
  
    –    TextField.ANY               –    TextField.PASSWORD
    –    TextField.NUMERIC           –    TextField.UNEDITABLE
    –    TextField.DECIMAL           –    TextField.NON_PREDICTIVE
    –    TextField.PHONENUMBER       –    TextField.INITIAL_CAPS_WORD
                                     –    TextField.
    –    TextField.EMAILADDR
                                          INITIAL_CAPS_SENTENCE
    –    TextField.URL
TextBox	
  Usage	
  
TextBox textbox =
new TextBox("Sähköposti",
            "",
            64,
            TextField.EMAILADDR |
            TextField.PASSWORD);
Displayable	
  Class	
  Hierarchy	
  
javax.microedi-on.lcdui	
                                            javax.microedi-on.lcdui.game	
  




                           Displayable	
                Canvas	
             GameCanvas	
  



                                  Screen	
  




          Alert	
      List	
           Form	
     TextBox	
  
Alerts	
  
•  There	
  are	
  two	
  types	
  of	
  alerts	
  
    –  Timed	
  Alert	
  
         •  Displayed	
  certain	
  amount	
  of	
  Ime	
  
    –  Modal	
  Alert	
  
         •  Demands	
  user	
  confirmaIon	
  


                                                              Modal	
  Alert	
  
Alert	
  -­‐	
  class	
  
•  Constructor	
  
   –  public Alert(String title, String
      alertText, Image alertImage,
      AlertType alerttype);!
•  Methods	
  
   –  setTimeOut(...)!
   –  setTimeOut(Alert.Forever)!
   –  addCommand(...)!
•  AlertTypes	
  
   –  ALARM, CONFIRMATION, ERROR, INFO,
      WARNING!
Displayable	
  Class	
  Hierarchy	
  
javax.microedi-on.lcdui	
                                            javax.microedi-on.lcdui.game	
  




                           Displayable	
                Canvas	
             GameCanvas	
  



                                  Screen	
  




          Alert	
      List	
           Form	
     TextBox	
  
EXCLUSIVE,	
  MULTIPLE	
  and	
  IMPLICIT	
  
ConstrucIng	
  Lists	
  
•  When	
  you	
  create	
  a	
  list,	
  you	
  define	
  list's	
  
   –  type	
  (EXCLUSIVE,	
  MULTIPLE,	
  IMPLICIT)	
  
   –  Itle	
  
    –  string	
  elements	
  and	
  images	
  (voluntary)	
  
•  API:	
  
     –    public List(String title, int type):
     –    public List(String title, int type, String [] stringelements, Image
          [] imageElements);

•  Scrolling	
  is	
  automaIcally	
  available	
  
•  It	
  is	
  possibly	
  to	
  add	
  elements	
  to	
  the	
  list	
  with	
  append-
   method.	
  
List	
  Example	
  1	
  
public class MyList extends MIDlet{
  private List mList;
  public MyList() {
    mList = new List(”Wanna Buy?”, Choice.MULTIPLE);
    mList.append(“Herring”, null);
    mList.append(“Goose Liver”, null);
    mList.append(“Jelly”, null);
  }
  public void startApp() {
     Display.getDisplay(this).setCurrent(mList);
  }
  public void destroyApp(boolean unconditional) {}
  public void pauseApp() {}
}
List	
  Example	
  2	
  

public MyList() {
 String [] elements =
 {"hyytelöä", "kananmaksaa",
 "ituja"};


 mLista = new List("Haluatko
 ostaa?", Choice.MULTIPLE,
 elements, null);


 }
Adding	
  and	
  Removing	
  List	
  elements	
  
•    It	
  is	
  possible	
  to	
  add	
  and	
  remove	
  list	
  elements	
  
•    The	
  elements	
  are	
  accessible	
  by	
  index	
  (0...n)	
  
•    Replacing	
  a	
  element:	
  set(...)	
  	
  
•    Adding	
  element:	
  append(...)	
  	
  
•    Adding	
  element	
  to	
  a	
  certain	
  place:	
  insert(...)
•    Finding	
  element:	
  String getString(int n)
•    Removing	
  element:	
  void delete(int n)
MIDP	
  2.0	
  List	
  
•  How	
  do	
  you	
  treat	
  the	
  elements,	
  if	
  they	
  don't	
  
   fit	
  into	
  mobile	
  device's	
  screen?	
  
    –  setPolicy(...);	
  
        •  Choice.TEXT_WRAP_ON,	
  Choice.TEXT_WRAP_OFF,	
  
           Choice.TEXT_WRAP_DEFAULT	
  
•  Changing	
  the	
  font:	
  
    –  setFont(...)	
  
List	
  SelecIon	
  
•  How	
  to	
  find	
  out	
  what	
  element	
  user	
  selected?	
  
    –  public boolean isSelected(int i)!
    –  public int getSelectedIndex()!
    –  public void setSelectedIndex(int i, boolean s)!

•  See	
  ListExample.java	
  
Displayable	
  Class	
  Hierarchy	
  
javax.microedi-on.lcdui	
                                            javax.microedi-on.lcdui.game	
  




                           Displayable	
                Canvas	
             GameCanvas	
  



                                  Screen	
  




          Alert	
      List	
           Form	
     TextBox	
  
Intro	
  to	
  Form	
  
•  Form	
  is	
  a	
  GUI-­‐component	
  that	
  can	
  hold	
  other	
  GUI-­‐
   components	
  	
  
•  These	
  othe	
  GUI-­‐components	
  are	
  called	
  items.	
  
•  If	
  there	
  are	
  many	
  items,	
  the	
  form	
  will	
  provide	
  
   scrolling	
  mechanism.	
  
•  Constructors:	
  
     –  public Form(String title)!
     –  public Form(String title, Item[] items)!
Handling	
  Items	
  
•  Adding	
  Items	
  to	
  the	
  Form:	
  
     –    Form a = new Form(“otsikko”);!
     –    a.append(Item item);!
     –    a.append(String str);!
     –    a.append(Image image);!
•  Every	
  item	
  has	
  an	
  index:	
  
     –  a.set(int index, Item item)!
     –  a.insert(int index, Item item)!
     –  a.delete(int index)!
•  Other	
  methods:	
  
     –  int size();!
     –  Item get(int index)!
Simple	
  Example	
  
mForm = new Form("Otsikko");
mForm.append("moi");
mForm.append("hei");
mForm.append("tere");
Using	
  Items	
  
•  There	
  are	
  many	
  items.	
  
•  javax.microedition.lcdui.Item:!
  –  ChoiceGroup!
  –  CustomItem // We will look this..!
  –  DateField!
  –  Gauge!
  –  ImageItem    // .. and this later!
  –  Spacer!
  –  StringItem!
  –  TextField!
Item	
  Layout	
  
•  Every	
  Form	
  item	
  can	
  have	
  a	
  layout:	
  
    –  LAYOUT_LEFT!
    –  LAYOUT_RIGHT!
    –  LAYOUT_CENTER!
    –  ...!
•  See	
  API!
Using	
  Item	
  Layout	
  
StringItem layoutLeft = new StringItem("Layout: ", "LEFT");
layoutLeft.setLayout(Item.LAYOUT_LEFT);


StringItem layoutCenter = new StringItem("Layout: ", "CENTER");
layoutCenter.setLayout(Item.LAYOUT_CENTER);


StringItem layoutRight = new StringItem("Layout: ", "RIGHT");
layoutRight.setLayout(Item.LAYOUT_RIGHT);


mForm.append(layoutLeft);
mForm.append(layoutCenter);
mForm.append(layoutRight);
StringItem	
  
•  Represents	
  a	
  simple	
  “Label”

Form form = new Form("Title");
StringItem st = new StringItem("Label: ";
                               "Value");
form.append(stringItem);
Item:	
  Spacer	
  
•  Spacer	
  provides	
  empty	
  space	
  in	
  the	
  form.	
  
    –  Spacer empty = new Spacer(100,50); !
Item:	
  TextField	
  

•  TextField:	
  
    –  public TextField
       (String label,
       String text, int
       maxSize, int
       constraints)!
•  Constraints	
  (same	
  as	
  in	
  
   TextBox)	
  
    –  ANY, NUMERIC,
       DECIMAL,
       PHONENUMBER,
       EMAILADDR, URL!
    –  PASSWORD, SENSITIVE;
       UNEDITABLE...!
Item:	
  DateField	
  
•  Date	
  and	
  Time	
  input.	
  
    –  public DateField(String label, int mode)!
    –  public DateField(String label, int mode,
       TimeZone timezone)!
•  mode	
  
    –  DATE, TIME, DATE_TIME!
•  Get	
  and	
  Set-­‐methods:	
  
    –  public Date getDate()!
    –  public void setDate()!
DateField	
  Images	
  
Item:	
  Gauge	
  
•  Gauge	
  presents	
  integer	
  in	
  a	
  graphical	
  form.	
  
    –  public Gauge(String label, boolean interactive,
       int maxValue, int initialValue)
•  By	
  using	
  parameter	
  interacIve	
  it	
  is	
  possible	
  to	
  define	
  
   can	
  the	
  user	
  modify	
  the	
  gauge.	
  
•  IniIalValue	
  can	
  also	
  be:	
  
    •    CONTINUOUS_IDLE !
    •    INCREMENTAL_IDLE !
    •    CONTINUOUS_RUNNING !
    •    INCREMENTAL_UPDATING !
Gauge	
  Images	
  

Gauge kake1 = new Gauge("Editoitava", true, 100, 0);


Gauge kake2 = new Gauge("Ei-editoitava", false, 100,
50);




 Gauge kake3 = new Gauge("INCREMENTAL_UPDATING",
 false, Gauge.INDEFINITE,
 Gauge.INCREMENTAL_UPDATING);
 Gauge kake6 = new Gauge("CONTINUOUS_RUNNING",
 false, Gauge.INDEFINITE,
 Gauge.CONTINUOUS_RUNNING);
Item:	
  ChoiceGroup	
  
•  Like	
  List	
  
     –  public ChoiceGroup(String label,
        int choiceType, String []
        elements, Image[] imageElements)!
•  Choicetype	
  
     –  EXCLUSIVE!
     –  MULTIPLE!
     –  MIDP 2.0: POPUP!
ChoiceGroup	
  Images	
  

String [] lista = {"suomi", "ruotsi"};
ChoiceGroup choicegroup = new ChoiceGroup("Valitse
maa", Choice.POPUP, lista, null);
Items	
  and	
  Event	
  Handling	
  
•  Instead	
  of	
  using	
  CommandListener	
  you	
  now	
  
   use	
  ItemStateListener.	
  
•  Set	
  the	
  event	
  source	
  to	
  form	
  and	
  the	
  listener	
  
   has	
  to	
  implement	
  ItemStateListener	
  interface.	
  
•  The	
  interface	
  has	
  only	
  one	
  method:	
  
    –  itemStateChanged(Item item)!
•  Example	
  

More Related Content

PDF
Reactive Feature Generation with Spark and MLlib by Jeffrey Smith (1)
DOC
PPTX
SharePoint 2010 Training Session 4
PDF
Google app engine cheat sheet
PDF
Building a SQL Database that Works
PDF
Chaco Step-by-Step
PDF
Database handling with room
Reactive Feature Generation with Spark and MLlib by Jeffrey Smith (1)
SharePoint 2010 Training Session 4
Google app engine cheat sheet
Building a SQL Database that Works
Chaco Step-by-Step
Database handling with room

Viewers also liked (9)

PDF
J2ME GUI Programming
PPT
Session2-J2ME development-environment
PPTX
Introduction To J2ME(FT - Prasanjit Dey)
PPT
Java ME CLDC MIDP
PPT
Session 3 J2ME Mobile Information Device Profile(MIDP) API
ODP
Programowanie na komórki
PDF
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
DOC
It6611 mobile application development laboratory l t p c0 0 3 2
DOCX
Cs 6611 mad lab manual
J2ME GUI Programming
Session2-J2ME development-environment
Introduction To J2ME(FT - Prasanjit Dey)
Java ME CLDC MIDP
Session 3 J2ME Mobile Information Device Profile(MIDP) API
Programowanie na komórki
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
It6611 mobile application development laboratory l t p c0 0 3 2
Cs 6611 mad lab manual
Ad

Similar to MIDP GUI Development: Alert, List, Form, TextBox (20)

PPTX
Nokia Asha App Development - Part 2
PPT
Scmad Chapter04
PPT
Mobile Application Development,J2ME,UNIT-4-JNTU
PPTX
High-Level Display: Screen J2ME User Interface
PPTX
Java ME - 02 - High Level UI
PPT
events,key,life cycle-abstract window tool kit,abstract class
PPT
Session5 J2ME High Level User Interface(HLUI) part1
PPT
Scmad Chapter05
PPTX
PPTX
Online birth certificate system and computer engineering
PPTX
Unit – I-AWT-updated.pptx
PPTX
Unit 5 java-awt (1)
PPT
Session7 J2ME High Level User Interface(HLUI) part1-2
PPTX
GUI programming
PPT
Introduction to j2me
PPTX
AWT stands for Abstract Window Toolkit. AWT is collection of classes and int...
PPTX
java-Unit4 chap2- awt controls and layout managers of applet
PDF
Notes netbeans
PDF
Intro to MIDP Development
PDF
Rich Internet Applications con JavaFX e NetBeans
Nokia Asha App Development - Part 2
Scmad Chapter04
Mobile Application Development,J2ME,UNIT-4-JNTU
High-Level Display: Screen J2ME User Interface
Java ME - 02 - High Level UI
events,key,life cycle-abstract window tool kit,abstract class
Session5 J2ME High Level User Interface(HLUI) part1
Scmad Chapter05
Online birth certificate system and computer engineering
Unit – I-AWT-updated.pptx
Unit 5 java-awt (1)
Session7 J2ME High Level User Interface(HLUI) part1-2
GUI programming
Introduction to j2me
AWT stands for Abstract Window Toolkit. AWT is collection of classes and int...
java-Unit4 chap2- awt controls and layout managers of applet
Notes netbeans
Intro to MIDP Development
Rich Internet Applications con JavaFX e NetBeans
Ad

More from Jussi Pohjolainen (20)

PDF
Moved to Speakerdeck
PDF
Java Web Services
PDF
Box2D and libGDX
PDF
libGDX: Screens, Fonts and Preferences
PDF
libGDX: Tiled Maps
PDF
libGDX: User Input and Frame by Frame Animation
PDF
Intro to Building Android Games using libGDX
PDF
Advanced JavaScript Development
PDF
Introduction to JavaScript
PDF
Introduction to AngularJS
PDF
libGDX: Scene2D
PDF
libGDX: Simple Frame Animation
PDF
libGDX: Simple Frame Animation
PDF
libGDX: User Input
PDF
Implementing a Simple Game using libGDX
PDF
Building Android games using LibGDX
PDF
Android Threading
PDF
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
PDF
Creating Games for Asha - platform
PDF
Intro to Asha UI
Moved to Speakerdeck
Java Web Services
Box2D and libGDX
libGDX: Screens, Fonts and Preferences
libGDX: Tiled Maps
libGDX: User Input and Frame by Frame Animation
Intro to Building Android Games using libGDX
Advanced JavaScript Development
Introduction to JavaScript
Introduction to AngularJS
libGDX: Scene2D
libGDX: Simple Frame Animation
libGDX: Simple Frame Animation
libGDX: User Input
Implementing a Simple Game using libGDX
Building Android games using LibGDX
Android Threading
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Games for Asha - platform
Intro to Asha UI

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Electronic commerce courselecture one. Pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Approach and Philosophy of On baking technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
KodekX | Application Modernization Development
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation theory and applications.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
sap open course for s4hana steps from ECC to s4
Review of recent advances in non-invasive hemoglobin estimation
Electronic commerce courselecture one. Pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Approach and Philosophy of On baking technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25 Week I
Digital-Transformation-Roadmap-for-Companies.pptx
KodekX | Application Modernization Development
Reach Out and Touch Someone: Haptics and Empathic Computing
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation theory and applications.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

MIDP GUI Development: Alert, List, Form, TextBox

  • 1. MIDP  GUI  Development:     Alert,  List,  Form,  TextBox   Jussi  Pohjolainen   Tampere  University  of  Applied  Sciences  
  • 2. Displayable  Class  Hierarchy   javax.microedi-on.lcdui   javax.microedi-on.lcdui.game   Displayable   Canvas   GameCanvas   Screen   Alert   List   Form   TextBox  
  • 3. TextBox   •  To  get  the  user  input   •  TextBox a = new TextBox(String title, String text, int maxSize, int constraints)
  • 4. Types  and  Flags   •  Types   •  Flags   –  TextField.ANY –  TextField.PASSWORD –  TextField.NUMERIC –  TextField.UNEDITABLE –  TextField.DECIMAL –  TextField.NON_PREDICTIVE –  TextField.PHONENUMBER –  TextField.INITIAL_CAPS_WORD –  TextField. –  TextField.EMAILADDR INITIAL_CAPS_SENTENCE –  TextField.URL
  • 5. TextBox  Usage   TextBox textbox = new TextBox("Sähköposti", "", 64, TextField.EMAILADDR | TextField.PASSWORD);
  • 6. Displayable  Class  Hierarchy   javax.microedi-on.lcdui   javax.microedi-on.lcdui.game   Displayable   Canvas   GameCanvas   Screen   Alert   List   Form   TextBox  
  • 7. Alerts   •  There  are  two  types  of  alerts   –  Timed  Alert   •  Displayed  certain  amount  of  Ime   –  Modal  Alert   •  Demands  user  confirmaIon   Modal  Alert  
  • 8. Alert  -­‐  class   •  Constructor   –  public Alert(String title, String alertText, Image alertImage, AlertType alerttype);! •  Methods   –  setTimeOut(...)! –  setTimeOut(Alert.Forever)! –  addCommand(...)! •  AlertTypes   –  ALARM, CONFIRMATION, ERROR, INFO, WARNING!
  • 9. Displayable  Class  Hierarchy   javax.microedi-on.lcdui   javax.microedi-on.lcdui.game   Displayable   Canvas   GameCanvas   Screen   Alert   List   Form   TextBox  
  • 11. ConstrucIng  Lists   •  When  you  create  a  list,  you  define  list's   –  type  (EXCLUSIVE,  MULTIPLE,  IMPLICIT)   –  Itle   –  string  elements  and  images  (voluntary)   •  API:   –  public List(String title, int type): –  public List(String title, int type, String [] stringelements, Image [] imageElements); •  Scrolling  is  automaIcally  available   •  It  is  possibly  to  add  elements  to  the  list  with  append- method.  
  • 12. List  Example  1   public class MyList extends MIDlet{ private List mList; public MyList() { mList = new List(”Wanna Buy?”, Choice.MULTIPLE); mList.append(“Herring”, null); mList.append(“Goose Liver”, null); mList.append(“Jelly”, null); } public void startApp() { Display.getDisplay(this).setCurrent(mList); } public void destroyApp(boolean unconditional) {} public void pauseApp() {} }
  • 13. List  Example  2   public MyList() { String [] elements = {"hyytelöä", "kananmaksaa", "ituja"}; mLista = new List("Haluatko ostaa?", Choice.MULTIPLE, elements, null); }
  • 14. Adding  and  Removing  List  elements   •  It  is  possible  to  add  and  remove  list  elements   •  The  elements  are  accessible  by  index  (0...n)   •  Replacing  a  element:  set(...)     •  Adding  element:  append(...)     •  Adding  element  to  a  certain  place:  insert(...) •  Finding  element:  String getString(int n) •  Removing  element:  void delete(int n)
  • 15. MIDP  2.0  List   •  How  do  you  treat  the  elements,  if  they  don't   fit  into  mobile  device's  screen?   –  setPolicy(...);   •  Choice.TEXT_WRAP_ON,  Choice.TEXT_WRAP_OFF,   Choice.TEXT_WRAP_DEFAULT   •  Changing  the  font:   –  setFont(...)  
  • 16. List  SelecIon   •  How  to  find  out  what  element  user  selected?   –  public boolean isSelected(int i)! –  public int getSelectedIndex()! –  public void setSelectedIndex(int i, boolean s)! •  See  ListExample.java  
  • 17. Displayable  Class  Hierarchy   javax.microedi-on.lcdui   javax.microedi-on.lcdui.game   Displayable   Canvas   GameCanvas   Screen   Alert   List   Form   TextBox  
  • 18. Intro  to  Form   •  Form  is  a  GUI-­‐component  that  can  hold  other  GUI-­‐ components     •  These  othe  GUI-­‐components  are  called  items.   •  If  there  are  many  items,  the  form  will  provide   scrolling  mechanism.   •  Constructors:   –  public Form(String title)! –  public Form(String title, Item[] items)!
  • 19. Handling  Items   •  Adding  Items  to  the  Form:   –  Form a = new Form(“otsikko”);! –  a.append(Item item);! –  a.append(String str);! –  a.append(Image image);! •  Every  item  has  an  index:   –  a.set(int index, Item item)! –  a.insert(int index, Item item)! –  a.delete(int index)! •  Other  methods:   –  int size();! –  Item get(int index)!
  • 20. Simple  Example   mForm = new Form("Otsikko"); mForm.append("moi"); mForm.append("hei"); mForm.append("tere");
  • 21. Using  Items   •  There  are  many  items.   •  javax.microedition.lcdui.Item:! –  ChoiceGroup! –  CustomItem // We will look this..! –  DateField! –  Gauge! –  ImageItem // .. and this later! –  Spacer! –  StringItem! –  TextField!
  • 22. Item  Layout   •  Every  Form  item  can  have  a  layout:   –  LAYOUT_LEFT! –  LAYOUT_RIGHT! –  LAYOUT_CENTER! –  ...! •  See  API!
  • 23. Using  Item  Layout   StringItem layoutLeft = new StringItem("Layout: ", "LEFT"); layoutLeft.setLayout(Item.LAYOUT_LEFT); StringItem layoutCenter = new StringItem("Layout: ", "CENTER"); layoutCenter.setLayout(Item.LAYOUT_CENTER); StringItem layoutRight = new StringItem("Layout: ", "RIGHT"); layoutRight.setLayout(Item.LAYOUT_RIGHT); mForm.append(layoutLeft); mForm.append(layoutCenter); mForm.append(layoutRight);
  • 24. StringItem   •  Represents  a  simple  “Label” Form form = new Form("Title"); StringItem st = new StringItem("Label: "; "Value"); form.append(stringItem);
  • 25. Item:  Spacer   •  Spacer  provides  empty  space  in  the  form.   –  Spacer empty = new Spacer(100,50); !
  • 26. Item:  TextField   •  TextField:   –  public TextField (String label, String text, int maxSize, int constraints)! •  Constraints  (same  as  in   TextBox)   –  ANY, NUMERIC, DECIMAL, PHONENUMBER, EMAILADDR, URL! –  PASSWORD, SENSITIVE; UNEDITABLE...!
  • 27. Item:  DateField   •  Date  and  Time  input.   –  public DateField(String label, int mode)! –  public DateField(String label, int mode, TimeZone timezone)! •  mode   –  DATE, TIME, DATE_TIME! •  Get  and  Set-­‐methods:   –  public Date getDate()! –  public void setDate()!
  • 29. Item:  Gauge   •  Gauge  presents  integer  in  a  graphical  form.   –  public Gauge(String label, boolean interactive, int maxValue, int initialValue) •  By  using  parameter  interacIve  it  is  possible  to  define   can  the  user  modify  the  gauge.   •  IniIalValue  can  also  be:   •  CONTINUOUS_IDLE ! •  INCREMENTAL_IDLE ! •  CONTINUOUS_RUNNING ! •  INCREMENTAL_UPDATING !
  • 30. Gauge  Images   Gauge kake1 = new Gauge("Editoitava", true, 100, 0); Gauge kake2 = new Gauge("Ei-editoitava", false, 100, 50); Gauge kake3 = new Gauge("INCREMENTAL_UPDATING", false, Gauge.INDEFINITE, Gauge.INCREMENTAL_UPDATING); Gauge kake6 = new Gauge("CONTINUOUS_RUNNING", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
  • 31. Item:  ChoiceGroup   •  Like  List   –  public ChoiceGroup(String label, int choiceType, String [] elements, Image[] imageElements)! •  Choicetype   –  EXCLUSIVE! –  MULTIPLE! –  MIDP 2.0: POPUP!
  • 32. ChoiceGroup  Images   String [] lista = {"suomi", "ruotsi"}; ChoiceGroup choicegroup = new ChoiceGroup("Valitse maa", Choice.POPUP, lista, null);
  • 33. Items  and  Event  Handling   •  Instead  of  using  CommandListener  you  now   use  ItemStateListener.   •  Set  the  event  source  to  form  and  the  listener   has  to  implement  ItemStateListener  interface.   •  The  interface  has  only  one  method:   –  itemStateChanged(Item item)! •  Example