Wednesday, January 12, 2011

Core J2ME Technology & MIDP






Table of Content
Table of Content ........................................................................................................................ i
Copyright................................................................................................................................. vii
Dedication .......................................................................................................................... viii
Preface................................................................................................................................... viii
Who Is This Book For....................................................................................................... viii
Focus of this Book .............................................................................................................. ix
Contents ............................................................................................................................... ix
Acknowledgments ................................................................................................................. xiii
About the Author.................................................................................................................... xiii
Chapter 1. THE BASICS Of J2ME......................................................................................... 1
Java Editions........................................................................................................................ 1
Why J2ME?.......................................................................................................................... 2
Configurations...................................................................................................................... 3
Profiles.................................................................................................................................. 3
Java Virtual Machines ......................................................................................................... 4
Big Picture View of the Architecture.................................................................................. 5
Compatibility between Java Editions ................................................................................ 6
Putting all the Pieces Together.......................................................................................... 7
Chapter 2. CONNECTED, LIMITED DEVICE CONFIGURATION (CLDC)..................... 8
Hardware Requirements..................................................................................................... 9
Software Requirements....................................................................................................... 9
The Java Virtual Machine Specification............................................................................ 9
Handling Security............................................................................................................... 11
Class File Verification........................................................................................................ 12
J2SE Inherited Classes..................................................................................................... 12
CLDC Specific Classes ..................................................................................................... 16
K Virtual Machine ............................................................................................................... 17
Chapter 3. MOBILE INFORMATION DEVICE PROFILE (MIDP)................................... 18
Hardware and Software Requirements .......................................................................... 18
MID Profile Architecture .................................................................................................... 19
The MIDlet Suite................................................................................................................. 20
Accessing JAR/JAD Attributes from a MIDlet................................................................ 24
Chapter 4. DEVELOPMENT ENVIORNMENT .................................................................. 27
Download the Software..................................................................................................... 27
Install the Software ............................................................................................................ 28
Command Line Development........................................................................................... 33
Packaging a MIDlet............................................................................................................ 36
Running a MIDlet on an Emulator ................................................................................... 39
Download MIDlet onto a Mobile Device.......................................................................... 41
Project Management Using Java Packages.................................................................. 41
J2ME Wireless Toolkit....................................................................................................... 45
Download ............................................................................................................................ 46
Installation ........................................................................................................................... 46
Create a New Project ........................................................................................................ 47
Configure the Project Settings ......................................................................................... 48
Write the Code and Build the Project.............................................................................. 51
Using Java Packages........................................................................................................ 53
Locating the JAR and JAD Files...................................................................................... 54
Configuring the Emulator .................................................................................................. 55
Toolkit Summary ................................................................................................................ 56
Chapter 5. BASICS OF MIDLETS AND THE DISPLAY................................................... 57
MIDlet.................................................................................................................................. 57
MIDletStateChangeException.......................................................................................... 61
Display ................................................................................................................................ 66
Displayable......................................................................................................................... 69
Chapter 6. EVENT HANDLING............................................................................................ 72
The Big Picture................................................................................................................... 72
Command Objects ............................................................................................................. 73
Item Objects........................................................................................................................ 74
Command and CommandListener .................................................................................. 75
Item and ItemStateListener .............................................................................................. 87
Chapter 7. HIGH-LEVEL USER INTERFACE: PART I .................................................... 91
Screen................................................................................................................................. 91
Form.................................................................................................................................... 93
Item ..................................................................................................................................... 94
DateField ............................................................................................................................. 98
Gauge ............................................................................................................................... 104
StringItem......................................................................................................................... 109
TextField........................................................................................................................... 115
Choice and ChoiceGroup ............................................................................................... 123
Image and ImageItem ..................................................................................................... 132
Chapter 8. HIGH-LEVEL USER INTERFACE: PART II ................................................. 146
List ..................................................................................................................................... 147
TextBox............................................................................................................................. 157
Alert and AlertType.......................................................................................................... 172
Ticker ................................................................................................................................ 180
Chapter 9. LOW-LEVEL USER INTERFACE.................................................................. 184
Canvas.............................................................................................................................. 184
Graphics ............................................................................................................................ 209
Chapter 10. CREATING A DISPLAYER MANAGER...................................................... 253
Animation MIDlet.............................................................................................................. 254
Display Manager API....................................................................................................... 257
Animating a Series of Images ........................................................................................ 260
Source Code..................................................................................................................... 262
Chapter 11. RECORD MANAGEMENT SYSTEM (RMS).............................................. 271
Persistent Storage Through the Record Store ............................................................ 271
Navigating with RecordEnumeration............................................................................. 284
Sorting with RecordComparator .................................................................................... 286
Searching with RecordFilter ........................................................................................... 303
Notification of Changes with RecordListener............................................................... 316
Exception Handling.......................................................................................................... 320
Chapter 12. TODO LIST EXAMPLE: PART I................................................................... 322
Using the Todo List.......................................................................................................... 322
Interface Design ............................................................................................................... 325
Data Design ...................................................................................................................... 326
Application Logic .............................................................................................................. 331
Source Code..................................................................................................................... 333
Chapter 13. SCHEDULING TASKS .................................................................................. 350
Timer ................................................................................................................................. 350
TimerTask ......................................................................................................................... 353
Example: Timer Template............................................................................................... 354
Example: Todo List MIDlet Part II—Delay Timer ........................................................ 358
Example: Animation with Timer/TimerTask ................................................................. 361
Chapter 14. GENERIC CONNECTION FRAMEWORK................................................. 369
Connection Hierarchy...................................................................................................... 369
HTTP Connection............................................................................................................. 371
Chapter 15. MIDP FOR THE PALM OS ........................................................................... 440
Device Requirements ...................................................................................................... 441
Download .......................................................................................................................... 442
Installation ......................................................................................................................... 442
MIDlets.............................................................................................................................. 444
Configuring Preferences ................................................................................................. 450
Example: keyCodes and gameActions......................................................................... 455
Appendix A. Over the Air User Initiated Provisioning Recommended Practice.......... 468
General Information......................................................................................................... 468
Device (Client) .................................................................................................................. 469
MIDlet Suite Upgrade ...................................................................................................... 473
MIDlet Suite Removal...................................................................................................... 473
Server ............................................................................................................................... 473
WAP.................................................................................................................................. 475
Appendix B. CLDC API........................................................................................................ 477
java.io................................................................................................................................ 480
ByteArrayInputStream..................................................................................................... 480
ByteArrayOutputStream.................................................................................................. 481
DataInput.......................................................................................................................... 481
DataInputStream.............................................................................................................. 482
DataOutput....................................................................................................................... 483
DataOutputStream........................................................................................................... 484
EOFException................................................................................................................... 484
InputStream...................................................................................................................... 485
InputStreamReader ......................................................................................................... 485
InterruptedIOException ................................................................................................... 486
IOException...................................................................................................................... 486
OutputStream ................................................................................................................... 486
OutputStreamWriter......................................................................................................... 487
PrintStream...................................................................................................................... 487
Reader ............................................................................................................................... 488
UnsupportedEncodingException ................................................................................... 489
UTFDataFormatException.............................................................................................. 489
Writer................................................................................................................................. 490
java.lang ............................................................................................................................ 490
ArithmeticException ......................................................................................................... 491
ArrayIndexOutOfBoundsException ............................................................................... 491
ArrayStoreException........................................................................................................ 491
Boolean............................................................................................................................. 492
Byte ................................................................................................................................... 492
Character.......................................................................................................................... 493
Class ................................................................................................................................. 494
ClassCastException......................................................................................................... 494
ClassNotFoundException ............................................................................................... 494
Error .................................................................................................................................. 495
Exception.......................................................................................................................... 495
IllegalAccessException ................................................................................................... 495
IllegalArgumentException ............................................................................................... 496
IllegalMonitorStateException.......................................................................................... 496
IllegalThreadStateException .......................................................................................... 496
IndexOutOfBoundsException......................................................................................... 496
InstantiationException ..................................................................................................... 497
Integer............................................................................................................................... 497
InterruptedException ....................................................................................................... 498
Long .................................................................................................................................. 498
Math .................................................................................................................................. 499
NegativeArraySizeException.......................................................................................... 499
NullPointerException ....................................................................................................... 500
NumberFormatException................................................................................................ 500
Object................................................................................................................................ 500
OutOfMemoryError .......................................................................................................... 501
Runnable ........................................................................................................................... 501
Runtime ............................................................................................................................. 501
RuntimeException............................................................................................................ 502
SecurityException ............................................................................................................ 502
Short.................................................................................................................................. 502
String................................................................................................................................. 503
StringBuffer ....................................................................................................................... 505
StringIndexOutOfBoundsException .............................................................................. 506
System.............................................................................................................................. 506
Thread............................................................................................................................... 507
Throwable......................................................................................................................... 508
VirtualMachineError......................................................................................................... 508
java.util.............................................................................................................................. 509
Calendar ............................................................................................................................ 509
Date................................................................................................................................... 511
EmptyStackException ..................................................................................................... 511
Enumeration..................................................................................................................... 511
Hashtable .......................................................................................................................... 512
NoSuchElementException.............................................................................................. 512
Random............................................................................................................................ 513
Stack ................................................................................................................................. 513
TimeZone .......................................................................................................................... 514
Vector................................................................................................................................ 514
javax.microedition.io ........................................................................................................ 515
Connection....................................................................................................................... 516
ConnectionNotFoundException ..................................................................................... 516
Connector......................................................................................................................... 516
ContentConnection.......................................................................................................... 517
Datagram.......................................................................................................................... 517
DatagramConnection....................................................................................................... 518
InputConnection ............................................................................................................... 518
OutputConnection............................................................................................................ 519
StreamConnection ........................................................................................................... 519
StreamConnectionNotifier............................................................................................... 519
Appendix C. MIDP API ........................................................................................................ 520
Alert: javax.microedition.lcdui.Alert ............................................................................... 522
AlertType: javax.microedition.lcdui.AlertType.............................................................. 522
Canvas: javax.microedition.lcdui.Canvas..................................................................... 523
Choice: javax.microedition.lcdui.Choice....................................................................... 524
ChoiceGroup: javax.microedition.lcdui.ChoiceGroup................................................. 524
Command: javax.microedition.lcdui.Command........................................................... 525
CommandListener: javax.microedition.lcdui.CommandListener............................... 526
DateField: javax.microedition.lcdui.DateField.............................................................. 526
Display: javax.microedition.lcdui.Display...................................................................... 527
Displayable: javax.microedition.lcdui.Displayable ...................................................... 527
Font: javax.microedition.lcdui.Font................................................................................ 528
Form: javax.microedition.lcdui.Form............................................................................. 528
Gauge: javax.microedition.lcdui.Gauge........................................................................ 529
Graphics: javax.microedition.lcdui.Graphics................................................................ 529
HttpConnection: javax.microedition.io.HttpConnection.............................................. 531
Image: javax.microedition.lcdui.Image.......................................................................... 536
ImageItem: javax.microedition.lcdui.ImageItem.......................................................... 536
Item: javax.microedition.lcdui.Item................................................................................ 537
ItemStateListener: javax.microedition.lcdui.ItemStateListener ................................. 537
List: javax.microedition.lcdui.List ................................................................................... 538
MIDlet: javax.microedition.midlet.MIDlet ...................................................................... 539
MIDletStateChangeException:
javax.microedition.midlet.MIDletStateChangeException ........................................... 539
RecordComparator: javax.microedition.rms.RecordComparator ............................. 539
RecordEnumeration: javax.microedition.rms.RecordEnumeration .......................... 540
RecordFilter: javax.microedition.rms.RecordFilter...................................................... 540
RecordListener: javax.microedition.rms.RecordListener ........................................... 541
RecordStore: javax.microedition.rms.RecordStore..................................................... 541
Record Store Exceptions ................................................................................................ 542
Screen: javax.microedition.lcdui.Screen ...................................................................... 543
StringItem: javax.microedition.lcdui.StringItem ........................................................... 543
TextBox: javax.microedition.lcdui.TextBox ...................................................................... 543
TextField: javax.microedition.lcdui.TextField............................................................... 544
Ticker: javax.microedition.lcdui.Ticker .......................................................................... 545
Timer: java.util.Timer....................................................................................................... 546
TimerTask: java.util.TimerTask...................................................................................... 546

Another J2ME Books
Another Programming Language Books
Download

No comments:

Post a Comment

Related Posts with Thumbnails

Put Your Ads Here!