SlideShare a Scribd company logo
1 of 27
Download to read offline
High Level UI Components
 Event Handling


           Cornelius Koo - 2005
What is Event Handling
• Process of recognizing when an event
  occurs and taking an action based on that
  event.
3 Steps in Event Management
1.The hardware must recognize that something
  has occured : button pressed, mouse clicked,
  mouse hover, an adapter plugged in etc.
2.The software on the device needs to be notified
  of the event.
3. A message from the application manager will be
  sent to the MIdlet. The message would contain
  information about the event, so that we can
  process it.
Scenario
Listener
• Before MIDlet can accept and process an
  event, it must implements Listener
  interfaces.

• There are 2 Listeners in MIDP :
  1. CommandListener
  2. ItemStateListener
public class TestCommandListener
  extends MIDlet implements
  CommandListener {
  ...
  public void commandAction(Command c,
  Displayable s) {…}
}
public class TestItemStateListener
  extends MIDlet implements
  ItemStateListener {
  ...
  public void itemStateChanged(Item
  item) {}
}
Command Object
• Command object is an object that holds
  information about an event.
Processing Events
• Processing events steps :
1. Create a Command object to hold
   information about an event.
2. Add the Command to a Form, Textbox,
   List or Canvas.
3. Add a "listener" to the above Form,
   Textbox, etc.
private Display display;
private Command cmExit;
private Form fmMain;

public TestDisplayable() {
    super();

    display = Display.getDisplay(this);
    fmMain = new Form("Displayable Form");
    cmExit = new Command("Exit", Command.EXIT, 1);

    fmMain.addCommand(cmExit);
    fmMain.setCommandListener(this);
}
…
Item Object
• Any components that can be added to a
  Form.
• ChoiceGroup, DateField, Gauge and
  TextField are all subclasses of Item and
  each can process events.
StringItem & ImageItem
• StringItem and ImageItem are also
  subclasses of Item however once
  allocated, these objects are static and thus
  do not receive/acknowledge events.
Command




1. Label
2. Type
3. Priority
label
• Specifies the text you would associate with
  the text.
type
• Specify the type of specific soft button.
priority
• Used by application manager when
  arranging items that appear in a menu or
  for ordering soft buttons on the display.
Command Types
Command & CommandListener API
Item
• Item is any component that can be added
  to the form.

• ChoiceGroup, CustomItem, DateField,
  Gauge, ImageItem, Spacer, StringItem,
  TextField.
ItemListener
• When an item’s value changed, it will
  generate an item event and sent it to
  ItemListener. (Except for StringItem and
  ImageItem)
When it is called ?
• If an Item has changed, itemStateChanged() must be
  called for the changed Item before it will
  acknowledge changes in a subsequent Item.

• If a MIDlet makes a change to an Item (not a user
  interaction), itemStateChanged() will not be called.

• If the device running the MIDlet can recognize when
  a user has moved from one Item to another,
  itemStateChanged() must be called when leaving one
  Item and before getting to the next.
Item & ItemListener API

  Item




  ItemListener
List Select Command
• We can change the select command for
  List and set it to our own command.
private List lsHero;
private Command cmOpen = new
     Command(“Open",Command.ITEM,1);
private String[] sound = {
               "Info",
               "Confirmation",
               "Warning",
               "Alarm",
               "Error“
};
...
lsHero = new List("Message Type",
          List.IMPLICIT, sound, null);
lsHero.setSelectCommand(cmOpen);
lsHero.setCommandListener(this);
...
public void commandAction(Command arg0,
     Displayable arg1) {
     if(arg0 == cmOpen){
        System.out.println(“Open selected");
        System.out.println(
           ((List)arg1)
                .getString(((List)arg1)
                .getSelectedIndex())
        );
     }
}
Reference
• Core J2ME Technology and MIDP. John
  W. Muchow. Prentice Hall PTR, 2002.
• Enterprise J2ME: Developing Mobile
  Java Applications. Michael Juntao Yuan.
  Prentice Hall PTR, 2003.
• J2ME in A Nutshell. Kim Topley. Oreilly,
  2002.

More Related Content

What's hot

Event Handling in Java
Event Handling in JavaEvent Handling in Java
Event Handling in JavaAyesha Kanwal
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03Ankit Dubey
 
Lesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFLesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFQuang Nguyễn Bá
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5sotlsoc
 
File Handling
File HandlingFile Handling
File HandlingSohanur63
 
Dr Jammi Ashok - Introduction to Java Material (OOPs)
 Dr Jammi Ashok - Introduction to Java Material (OOPs) Dr Jammi Ashok - Introduction to Java Material (OOPs)
Dr Jammi Ashok - Introduction to Java Material (OOPs)jammiashok123
 
Advance java for bscit
Advance java for bscitAdvance java for bscit
Advance java for bscitYogeshDhamke2
 
behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)Lokesh Singrol
 
Java gui event
Java gui eventJava gui event
Java gui eventSoftNutx
 
Ordenar vectores
Ordenar vectoresOrdenar vectores
Ordenar vectoresecasteloc
 
Ordenar vector
Ordenar vectorOrdenar vector
Ordenar vectorecasteloc
 
Chapter11 graphical components
Chapter11 graphical componentsChapter11 graphical components
Chapter11 graphical componentsArifa Fatima
 
Laboratory activity 3 b2
Laboratory activity 3 b2Laboratory activity 3 b2
Laboratory activity 3 b2Jomel Penalba
 
5.state diagrams
5.state diagrams5.state diagrams
5.state diagramsAPU
 

What's hot (20)

Event Handling in Java
Event Handling in JavaEvent Handling in Java
Event Handling in Java
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03
 
What is Event
What is EventWhat is Event
What is Event
 
Lesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFLesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPF
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
 
Events1
Events1Events1
Events1
 
File Handling
File HandlingFile Handling
File Handling
 
Dr Jammi Ashok - Introduction to Java Material (OOPs)
 Dr Jammi Ashok - Introduction to Java Material (OOPs) Dr Jammi Ashok - Introduction to Java Material (OOPs)
Dr Jammi Ashok - Introduction to Java Material (OOPs)
 
Advance java for bscit
Advance java for bscitAdvance java for bscit
Advance java for bscit
 
State Diagram
State DiagramState Diagram
State Diagram
 
behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)
 
Java gui event
Java gui eventJava gui event
Java gui event
 
Ordenar vectores
Ordenar vectoresOrdenar vectores
Ordenar vectores
 
Ordenar vector
Ordenar vectorOrdenar vector
Ordenar vector
 
Seminar State Chart1
Seminar State Chart1Seminar State Chart1
Seminar State Chart1
 
Chapter11 graphical components
Chapter11 graphical componentsChapter11 graphical components
Chapter11 graphical components
 
Trabajo de case
Trabajo de caseTrabajo de case
Trabajo de case
 
Laboratory activity 3 b2
Laboratory activity 3 b2Laboratory activity 3 b2
Laboratory activity 3 b2
 
Trabajo de case
Trabajo de caseTrabajo de case
Trabajo de case
 
5.state diagrams
5.state diagrams5.state diagrams
5.state diagrams
 

Similar to 12 High Level UI Event Handling

Session4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) EventsSession4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) Eventsmuthusvm
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intentPERKYTORIALS
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptxusvirat1805
 
Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Marlon Luz
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptsharanyak0721
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptxGood657694
 
Android webinar class_3
Android webinar class_3Android webinar class_3
Android webinar class_3Edureka!
 
openFrameworks 007 - events
openFrameworks 007 - eventsopenFrameworks 007 - events
openFrameworks 007 - eventsroxlu
 

Similar to 12 High Level UI Event Handling (20)

Session4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) EventsSession4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) Events
 
7java Events
7java Events7java Events
7java Events
 
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing ButtonsJAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
 
Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 
Java-Events
Java-EventsJava-Events
Java-Events
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
 
09events
09events09events
09events
 
Android webinar class_3
Android webinar class_3Android webinar class_3
Android webinar class_3
 
Androd Listeners
Androd ListenersAndrod Listeners
Androd Listeners
 
IoT in salsa Serverless
IoT in salsa ServerlessIoT in salsa Serverless
IoT in salsa Serverless
 
Module3.11.pptx
Module3.11.pptxModule3.11.pptx
Module3.11.pptx
 
unit3.pptx
unit3.pptxunit3.pptx
unit3.pptx
 
openFrameworks 007 - events
openFrameworks 007 - eventsopenFrameworks 007 - events
openFrameworks 007 - events
 
Swing
SwingSwing
Swing
 
Awt event
Awt eventAwt event
Awt event
 
Module 5.pptx
Module 5.pptxModule 5.pptx
Module 5.pptx
 

More from corneliuskoo

More from corneliuskoo (15)

Basic JSTL
Basic JSTLBasic JSTL
Basic JSTL
 
Expression Language in JSP
Expression Language in JSPExpression Language in JSP
Expression Language in JSP
 
JSP
JSPJSP
JSP
 
Html Hands On
Html Hands OnHtml Hands On
Html Hands On
 
13 Low Level UI Event Handling
13 Low Level UI Event Handling13 Low Level UI Event Handling
13 Low Level UI Event Handling
 
09 Display
09 Display09 Display
09 Display
 
08 Midlet Basic
08 Midlet Basic08 Midlet Basic
08 Midlet Basic
 
07 Midlet On The Web
07 Midlet On The Web07 Midlet On The Web
07 Midlet On The Web
 
06 Eclipse ME
06 Eclipse ME06 Eclipse ME
06 Eclipse ME
 
05 J2ME Wtk Command Line
05 J2ME Wtk Command Line05 J2ME Wtk Command Line
05 J2ME Wtk Command Line
 
04 J2ME Wireless Tool Kit
04 J2ME Wireless Tool Kit04 J2ME Wireless Tool Kit
04 J2ME Wireless Tool Kit
 
03 midp
03 midp03 midp
03 midp
 
02a cldc property support
02a cldc property support02a cldc property support
02a cldc property support
 
02 cldc
02 cldc02 cldc
02 cldc
 
01 java 2 micro edition
01 java 2 micro edition01 java 2 micro edition
01 java 2 micro edition
 

Recently uploaded

John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfAmzadHosen3
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsP&CO
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1kcpayne
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with CultureSeta Wicaksana
 
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...amitlee9823
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...lizamodels9
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdfRenandantas16
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Serviceritikaroy0888
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...amitlee9823
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLkapoorjyoti4444
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...daisycvs
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...rajveerescorts2022
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Sheetaleventcompany
 

Recently uploaded (20)

John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and pains
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
 

12 High Level UI Event Handling

  • 1. High Level UI Components Event Handling Cornelius Koo - 2005
  • 2. What is Event Handling • Process of recognizing when an event occurs and taking an action based on that event.
  • 3. 3 Steps in Event Management 1.The hardware must recognize that something has occured : button pressed, mouse clicked, mouse hover, an adapter plugged in etc. 2.The software on the device needs to be notified of the event. 3. A message from the application manager will be sent to the MIdlet. The message would contain information about the event, so that we can process it.
  • 5. Listener • Before MIDlet can accept and process an event, it must implements Listener interfaces. • There are 2 Listeners in MIDP : 1. CommandListener 2. ItemStateListener
  • 6. public class TestCommandListener extends MIDlet implements CommandListener { ... public void commandAction(Command c, Displayable s) {…} }
  • 7. public class TestItemStateListener extends MIDlet implements ItemStateListener { ... public void itemStateChanged(Item item) {} }
  • 8. Command Object • Command object is an object that holds information about an event.
  • 9. Processing Events • Processing events steps : 1. Create a Command object to hold information about an event. 2. Add the Command to a Form, Textbox, List or Canvas. 3. Add a "listener" to the above Form, Textbox, etc.
  • 10. private Display display; private Command cmExit; private Form fmMain; public TestDisplayable() { super(); display = Display.getDisplay(this); fmMain = new Form("Displayable Form"); cmExit = new Command("Exit", Command.EXIT, 1); fmMain.addCommand(cmExit); fmMain.setCommandListener(this); } …
  • 11. Item Object • Any components that can be added to a Form. • ChoiceGroup, DateField, Gauge and TextField are all subclasses of Item and each can process events.
  • 12. StringItem & ImageItem • StringItem and ImageItem are also subclasses of Item however once allocated, these objects are static and thus do not receive/acknowledge events.
  • 14. label • Specifies the text you would associate with the text.
  • 15. type • Specify the type of specific soft button.
  • 16. priority • Used by application manager when arranging items that appear in a menu or for ordering soft buttons on the display.
  • 19. Item • Item is any component that can be added to the form. • ChoiceGroup, CustomItem, DateField, Gauge, ImageItem, Spacer, StringItem, TextField.
  • 20. ItemListener • When an item’s value changed, it will generate an item event and sent it to ItemListener. (Except for StringItem and ImageItem)
  • 21. When it is called ? • If an Item has changed, itemStateChanged() must be called for the changed Item before it will acknowledge changes in a subsequent Item. • If a MIDlet makes a change to an Item (not a user interaction), itemStateChanged() will not be called. • If the device running the MIDlet can recognize when a user has moved from one Item to another, itemStateChanged() must be called when leaving one Item and before getting to the next.
  • 22. Item & ItemListener API Item ItemListener
  • 23. List Select Command • We can change the select command for List and set it to our own command.
  • 24. private List lsHero; private Command cmOpen = new Command(“Open",Command.ITEM,1); private String[] sound = { "Info", "Confirmation", "Warning", "Alarm", "Error“ };
  • 25. ... lsHero = new List("Message Type", List.IMPLICIT, sound, null); lsHero.setSelectCommand(cmOpen); lsHero.setCommandListener(this); ...
  • 26. public void commandAction(Command arg0, Displayable arg1) { if(arg0 == cmOpen){ System.out.println(“Open selected"); System.out.println( ((List)arg1) .getString(((List)arg1) .getSelectedIndex()) ); } }
  • 27. Reference • Core J2ME Technology and MIDP. John W. Muchow. Prentice Hall PTR, 2002. • Enterprise J2ME: Developing Mobile Java Applications. Michael Juntao Yuan. Prentice Hall PTR, 2003. • J2ME in A Nutshell. Kim Topley. Oreilly, 2002.