SlideShare a Scribd company logo
1 of 33
Download to read offline
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

Viewers also liked

Session2-J2ME development-environment
Session2-J2ME development-environmentSession2-J2ME development-environment
Session2-J2ME development-environmentmuthusvm
 
Introduction To J2ME(FT - Prasanjit Dey)
Introduction To J2ME(FT - Prasanjit Dey)Introduction To J2ME(FT - Prasanjit Dey)
Introduction To J2ME(FT - Prasanjit Dey)Fafadia Tech
 
Java ME CLDC MIDP
Java ME CLDC MIDPJava ME CLDC MIDP
Java ME CLDC MIDPSMIJava
 
Session 3 J2ME Mobile Information Device Profile(MIDP) API
Session 3 J2ME Mobile Information Device Profile(MIDP)  APISession 3 J2ME Mobile Information Device Profile(MIDP)  API
Session 3 J2ME Mobile Information Device Profile(MIDP) APImuthusvm
 
Programowanie na komórki
Programowanie na komórkiProgramowanie na komórki
Programowanie na komórkiAdam Sawicki
 
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
"JavaME + Android in action" CCT-CEJUG Dezembro 2008"JavaME + Android in action" CCT-CEJUG Dezembro 2008
"JavaME + Android in action" CCT-CEJUG Dezembro 2008Vando Batista
 
It6611 mobile application development laboratory l t p c0 0 3 2
It6611 mobile application development laboratory l t p c0 0 3 2It6611 mobile application development laboratory l t p c0 0 3 2
It6611 mobile application development laboratory l t p c0 0 3 2MNM Jain Engineering College
 

Viewers also liked (9)

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

Similar to MIDP GUI Development: Alert, List, Form, TextBox

Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Marlon Luz
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans Fabrizio Giudici
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesAndrew Ferlitsch
 
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...HendraPurnama31
 
Unit – I-AWT-updated.pptx
Unit – I-AWT-updated.pptxUnit – I-AWT-updated.pptx
Unit – I-AWT-updated.pptxssuser10ef65
 
Lists and scrollbars
Lists and scrollbarsLists and scrollbars
Lists and scrollbarsmyrajendra
 
python-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptxpython-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptxAkashgupta517936
 
Taxonomy of Scala
Taxonomy of ScalaTaxonomy of Scala
Taxonomy of Scalashinolajla
 
Lecture20 vector
Lecture20 vectorLecture20 vector
Lecture20 vectornurkhaledah
 
02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.pptYonas D. Ebren
 
Text field and textarea
Text field and textareaText field and textarea
Text field and textareamyrajendra
 
Introduction to JavaScript design patterns
Introduction to JavaScript design patternsIntroduction to JavaScript design patterns
Introduction to JavaScript design patternsJeremy Duvall
 

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

Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
 
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
 
Unit – I-AWT-updated.pptx
Unit – I-AWT-updated.pptxUnit – I-AWT-updated.pptx
Unit – I-AWT-updated.pptx
 
Lists and scrollbars
Lists and scrollbarsLists and scrollbars
Lists and scrollbars
 
Java
Java Java
Java
 
Python: The Dynamic!
Python: The Dynamic!Python: The Dynamic!
Python: The Dynamic!
 
python-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptxpython-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptx
 
GWT Widgets
GWT WidgetsGWT Widgets
GWT Widgets
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
 
Taxonomy of Scala
Taxonomy of ScalaTaxonomy of Scala
Taxonomy of Scala
 
Lecture20 vector
Lecture20 vectorLecture20 vector
Lecture20 vector
 
02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt
 
Java 103
Java 103Java 103
Java 103
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Text field and textarea
Text field and textareaText field and textarea
Text field and textarea
 
Introduction to JavaScript design patterns
Introduction to JavaScript design patternsIntroduction to JavaScript design patterns
Introduction to JavaScript design patterns
 

More from Jussi Pohjolainen

libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferencesJussi Pohjolainen
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationJussi Pohjolainen
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDXJussi Pohjolainen
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript DevelopmentJussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDXJussi Pohjolainen
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDXJussi Pohjolainen
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesJussi Pohjolainen
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platformJussi Pohjolainen
 

More from Jussi Pohjolainen (20)

Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
 
Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
 
Intro to Asha UI
Intro to Asha UIIntro to Asha UI
Intro to Asha UI
 

Recently uploaded

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.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