Вы находитесь на странице: 1из 331

. .

Java 2 Micro Edition


-
-qucK

" !

^^**^'-"" '

. .


JAVA 2 MICRO EDITION

, 2005

004.438
32.973.26-018.2

26

. .
Java 2 Micro Edition. - .:
, 2004. - 336 .: .
ISBN 5-94074-279-3
, , Java 2
Micro Edition,
. Java 2 Micro Edition,
.
MIDP 1.0 MIDP 2.0,
. , ,
, .
, .
Sun Microsystems. Sun ONE Studio 4 Mobile Edition Wireless Toolkit 2.1,
Nokia, Siemens, Sony Ericsson, Motorola, Samsung .
, Java 2
Micro Edition. Java, .
, , , Java 2 Micro Edition.
004.438
32.973.26-018.2
.
.
, , .
,
. , .

ISBN 5-94074-279-3

. ., 2005
, , 2005

11




...:....
-

1. .,
1.1. GSM
1.2.
1.3.
1.4.
1.5. Bluetooth
,..
1.6. WAP
1.7. GPRS
1.8. SIM

..

2. Java 2 Micro Edition


2.1. CDC
2.2. CLDC
2.2.1. Java
2.2.2. ...
2.3.
2.4. MIDP 2.0 CLDC 1.0
2.4.1 Java.lang
,
2.4.2. java.util
2.4.3. java.io
2.4.4. javax.microedition.io
2.4.5. javax.microedition.lcdui
2.4.6. javax.microedition.lcdui.game
2.4.7. javax.microedition.media
2.4.8. javax.microedition.media.control
2.4.9. javax.microedition.midlet
2.4.10. javax.microedition.pki
2.4.11. javax.microedition.rms

12
13
13
14
15
...15
15

16
17
17
17
18
19
19
20
21

22
24
25
26
26
27
29
29
.31
'.
32
34
35
37
....37
.-..,
..38
38
39
39


3. ... 41
3.1. Java 2 SDK SE
41
3.2. SUN ONE Studio 4 Mobile Edition ... 42
3.2.1. SUN ONE Studio 4 Mobile Edition
44
3.2.2. SUN ONE Studio 4 Mobile Edition .... 50
3.2.3.
SUN ONE Studio 4 Mobile Edition
53
3.2.4.
SUN ONE Studio 4 Mobile Edition
.55
3.3. J2ME Wireless Toolkit 2.1
57
3.3.1. J2ME Wireless Toolkit 2.1
57
3.3.2. J2ME Wireless Toolkit 2.1
60
3.3.3.
J2ME Wireless Toolkit 2.1
63
3.4.
64
3.4.1.
64
3.4.2. JAD
65
3.4.3. JAR
:
..66

4.

68

4.1. Nokia
69
4.1.1. Nokia Developer's Suite 2.0 for J2ME ...72
4.1.2. Nokia PC Suite 5.1
77
4.1.3. Nokia
78
4.2. Siemens
78
4.2.1. Siemens Mobility Toolkit
79
4.2.2. Siemens Date Suite
81
4.2.2. Siemens
81
4.3. Sony Ericsson
83
4.4. Motorola
85
4.5. Samsung
86

5. Java 2 ME
5.1.
5.1.1.
5.2.
5.3.
5.4.

6.
6.1. Form..

89
*

89
...95
97
99
>.... 104

111
..111


. 6..1. Form
6.2. Item
6.2.1. ChoiceGroup
6.2.2. DateField
6.2.3. TextField
6.2.4. Stringltem
6.2.5. Spacer
6.2.6. Imageltem....
6.2.7.
toiaccGauge
6.3. Alert.
6.3.1. Alert
,
6.4. List
6.4.1. List
6.5. Ticker
6.5.1. Ticker
6.6.1< Image
6.6.1. Image
6.7. Font

IllHBHI

-..
.,

112
114
116
122
125
128
.. 133
135
139
142
142
145
146
152
152
154
154
, 156

?.
7.1. Canvas
...*...'..
7.1.1. Canvas
7.2. Graphics
7.2.1. Graphics
7.3.
:...
7.4.
7.5.
7.6.
7.7.
7.8.
7.9.
7.10.
7.11.

162
162
163
164
164
167
170
174
177
178
180
184
187
190

8.

195

8.1. GameCanvas
8.2. Layer
8.3. TiledLayer
8.4. LayerManager
8.5. Sprite
8.6.

196
197
198
199
200
201


2.3.6. DataOutputStream
2.3.7. InputStream
2.3.8. InputStreamReader
2.3.9. OutputStream
2.3.10. OutputStreamWriter
2.3.11. PrintStream
2.3.12. Reader
2.3.13. Writer
2.3.14.
2.4. javax.micro-edition.io
;
2.4.1. CommConnection
2.4.2. Connection
2.4.3. ContentConnection
2.4.4. Datagram
2.4.5. DatagramConnection
2.4.6. HttpConnection
,
2.4.7. HttpsConnection
2.4.8. InputConnection
2.4.9. OutputConnection
2.4.10. SecureConnection
2.4.11. Securitylnfo
2.4.12. ServerSocketConnection
2.4.13. SocketConnection
2.4.14. StreamConnection
2.4.15. StreamConnectionNotifier
2.4.16. UDPDatagramConnection
2.4.17. Connector
2.4.18. PushRegistry
2.4.19.
2.5. javax,microedition.lcdui
2.5.1. Choice
2.5.2. CommandListener
2.5.3. ItemCommandListener
2.5.4. ItemStateListener
2.5.5. Alert
2.5.6. AlertType
2.5.7. Canvas
2.5.8. ChoiceGroup
2.5.9. Command
...'
2.5.10. Customltem .

:
:

290
291
291
292
292
293
294
..294
295
295
295
295
295
296
296
....296
298
298
298
298
298
299
299
299
299
299
300
300
301
301
301
;.... 302
302
302
302
303
303
305
306
..307


2.5.11. DateField
2.5.12. Display
2.5.13. Displayable
2.5.14. Font
.';
2.5.15. Form.....
2.5.16. Gauge
2.5.17. Graphics
2.5.18. Image
2.5.19. Imageltem
2.5.20. Item
2.5.21. List
2.5.22. Screen
2.5.23. Spacer
2.5.24. Stringltem
2.5.25. TextBox
2.5.26. TextField
2.5.27. Ticker
2.6. javax.microedition.lcdui.game
2.6.1. GameCanvas
2.6.2. Layer
2.6.3. LayerManager
2.6.4. Sprite
2.6.5. TiledLayer
2.7. javax.microedition.media
\........
2.7.1. Control
2.7.2. Controllable ....,
2.7.3. Player
2.7.4. PlayerListener
.....
2.7.5. Manager
2.7.6.
2.8. javax.microedition.media.control
2.8.1. ToneControl
2.8.2. VolumeControl
2.9. javax.microedition.midlet
2.9.1. MIDIet
2.9.2.
2.10. javax.microedition.pki...
2.10.1. Certificate..
2.10.2.
2.11. javax.microedition.rms

..308
308
310
310
311
:
....:. 312
313
315
315
,
316
317
318
318
318
:.
319
320
321
321
321
322
322
..323
324
324
324
324
325
325
326
326
326
.;
326
.'
327
327
..327
328
328
328
328
328


2.11.1. RecordComparator
2.11.2. RecordEnumeration
2.11.3. RecordFilter
2.11.4. Record Listener
2.11.5. RecordStore

..,

328
329
329
329
330

3. -

331

333

334

- , , . - . . ,
, .

.
. , , , -
, ?

. ,
, .
,
. - ,
, , . , , , , .
, Java 2 Micro Edition, Sun Microsystems.
Java 2 ME Java , Java ,
. Java ,
Java , , Java . Java
, Java.
Java , .
.
-
, . , , , ,
. .
, , Nokia, -


, . Java 2 ME .
, Java, , Java 2 ME. , ?
, . , .
, Java 2 ME,
Java. ,
,
, . Siemens 101x80,
Nokia 128x128

. , . , , , .
, . , Java 2 ME ,
.
. . , ,
Palm Pocket PC.

, Java 2 ME, .
Java 2 ME ,
Java .
, Sun Microsystems ! , Java 2 ME.
-
, Java 2 ME.


Java 2 ME,
.

1
1
I
M
H
I

, 1 Java.
1, Java 2 ME
, . , Java, .

. Java 2 ME.


, . Windows XP
Microsoft. .
-
Java 2 ME.
- Sun Microsystems,
Siemens, Nokia, Sony Ericsson, Motorola Samsung. -
.
- 3.


Java, . Java 2 ME,
, , Java 2 ME. , . 2 ,
, , Java 2 Micro Edition.
,
, .
Java 2.
MIDP 1.0 MIDP .2.0, ,
. Java 2 ME ,
.
,
, . .: Sun ONE Studio 4
Mobile Edition J2ME Wireless Toolkit 2.1. .



(SDK), . Nokia, Siemens, Sony Ericsson,
Motorola Samsung.
. SDK , 3,
- .
Java ,
, Java .
Java 2 ME .
,
.
MIDP 1.0. ,
.
,
MIDP 2.O. , ,
.
,
.
1 Java.

.
2 , , Java 2 ME. ,
Java 2 ME.
3 - .

-
- .
: Sun ONE Studio 4 Mobile Edition J2ME Wireless Toolkit 2.1
Sun Microsystems,
Nokia, Siemens, Sony Ericsson, Motorola, Samsung.


,
Java 2 ME. - \Code. , , \Code, ,
: \Code\Listing6_3. , 6.3, \Code. ,
.

, , . , ! -
. .


.
.
DirectX 9. C++.
: Java2ME@mail.ru.

1.
Java 2 ME, .
,
,
. , .

, . . SMS ,
(Short Message Service ). , , , , , , ,
.
. , 80
130 . ,
. - Java. WAP (Wireless Application Protocol - ) GPRS (General Packet Radio Service -
). 1.6 1.7 .
-. , (),
.
- ,

.
,
. ,
,
, . , GSM.

1.1. GSM
GSM (Global System Mobile Communication -
), , - , 900/1800/1900 .
GSM , . ,
.

1.2.
, , , .
, , -, , , SIM (Subscriber identification module ). . ,
. - -'
, , .
( )
.
.
() , , .

1.3.
-
, ,
. . , , Windows Mobile Symbian.
Windows Mobile, , , Microsoft . , .
, Windows Mobile -
,
.
Symbian
. -


Symbian Ltd. ( Symbian)
. .
, ,
, , , ,
. , : 1999 200
, .
- , ,
.
, .

, . ,
Java 2 ME. Java, Java . Java ,
, , , , ,
Java
, Java .
, , , .
, , Java- ,
.
Java- ,
Java .
, .
Java
, . ,
Bluetooth, WAP
GPRS. , ,
, JAD *- JAR - . 3.

1.4.
. , ,
. , . :

WAP
, .

.
,
. Sony Ericsson, Nokia Siemens,
3.

1.5. Bluetooth
(Bluetooth - ) - ,
.
Bluetooth
.
Bluetooth 2,4
10 , ,
.
.
Bluetooth
, .

1.6. WAP
WAP (Wireless Application Protocol) -
. WAP , web- . WAP , Java.
1-2 . WAP
, WAP . , WAP, WAP-, WAP .
, WAP,
, , -,
HTML XML, WAP-
WML (Wireless Markup Language - ).
WAP , .
, , . -


SMS,
, SIM-. WAP
, , 1.1.
1.1.

URL


IP


http://wap.beeline.ru

GPRS
http://wap.beeline.ru
192.168.017.001
beeline
beeline

http://wap.megawap.ru

GPRS
http://wap.megawap.ru
010.010.001.002
wap
wap
,

http://wap.mts'.ru

GPRS
http://wap.mts.ru
212.44.140.13
mts
mts

,
SMS, , . , .
WAP- - , ,
. .
GPRS.

1.7. GPRS
GPRS (General Packet Radio Service -
) . WAP, ,
,
. GPRS , , .
, 60 ( 2004 ).
WAP , WAP-, GPRS, . , GPRS - , ,
.
115 /, , , 3040 / . GPRS , .
.

SIM

1.8. SIM
SIM- . SIM-,
.
SIM-
, . SIM-, , . SIM- ,
SIM- , , ,
200-300 . SIM- .
, . . Java 2 ME,
, , , . Java 2 Micro Edition.

2. Java 2 Micro Edition


Java 2 ME, Java. ,
Java. , 1 Java.
, .
Java . , Java, . Java, ,
, , , ,
. ,
Java . , . World Wide Web, Java , . Sun Microsystems
. .
Q Java 2 Enterprise Edition - ;
Q Java 2 Standard Edition - ;
Q Java 2 Micro Edition .
.
Java 2 Java 2 SE
, Java 2 ME
. : , Java, , , .
Java 2 ME, ?
.
Java , , , -, - .
, Java .
. ,

Java 2 Micro Edition

, Java, Java Language Specification, Sun Microsystems.


Java Java API, . Java API , , ,
.

Java 2 , Java 2 SE Java 2 ME. Java 2
Java 2 SE , Java 2
, Java 2 ME
. Java 2 ME
Java ,
Java , . , , , , Java 2 ME
, ' ,
.
Java, . ,
, , Java.
Java , , , .
Java 2 ME , .
Java Java ,
Java API.

Java, .
Java 2 ME : CDC (Connected Device Configuration - ) CLDC (Connected
Limited Device Configuration - ).
. CLDC. , .
, ,

.
- ,

Java 2 Micro Edition


.
, .
. 2.1 Java 2 ME.

Java 2 ME

Java 2 SE

Java 2

Personal

Foundation

MIDP

CDC

Java

Java

Java

' CLDC

Java

. 2.1. Java 2 ME
. , .,
, ,
, .
.
CLDC MIDP.
MIDP/CLDC, CDC .

2.1. CDC
CDC
, , , , .
,
16 32- 2
. CDC CLDC, ,
Java API, ,
Java. .
,
. , API
.

CLDC
, .
, .
. CDC
- Foundation Profile Personal Profile PDA.
,

. Java 2 ME .

2.2. CLDC
CLDC ,
, , . , CLDC, :
G !6 32-;
G 160 512 , Java 2 ME;
Q ;
.
, ,
. CDC CLDC . CLDC Java Community Process, Sun Microsystems, :
Q America Online;
Q Bull;
Ericsson;
G Fujitsu;
Q Matsushita;
Q Mitsubishi;
G Motorola;
a Nokia;
0 NTT DoCoMo;
Q Oracle;
G Palm Computing;
a RIM;
G Samsung;
01 Sharp;
G Siemens;
G Sony;
G Sun Microsystems;
G Symbian.
CLDC , , Java 2 SE, . ,

I
l
l
l
i
l

Java 2 Micro Edition

. ,,
,
,
. , Java 2 ME,
.
CLDC
Java, Java API. - CLDC 1.0 CLDC 1.1.
CLDC 1.1 ,
, . , CLDC 1.0. , CLDC 1.1 .
CLDC 1.0 . , CLDC 1.0.

2.2.1. Java
Java CLDC , , Java, , Java 2 Java 2 SE:
1) (floating point);
2) (finalization);
3) (error handling).

2.2.2.
, CLDC, Java, (Java Virtual
Machine Specification). .
Kilobyte Virtual Machine (KVM) - :
1) (floating point);
2) (class loader);
3) (reflection);
4) Java Nativ (Java Native Interface);
5) (finalization);
6) (error handling);
7) (Thread group).
Java Java , ,


, , .
( .
.
'

2.3.

,
, API
. CLDC MIDP (Mobile
Information Device Profile - ).
MIDP Expert Group,
:
Q America Online;
a DDI;
Q Ericsson;
Q Espial Group, Inc.;
Q Fujitsu;
Q Hitachi;
Q J-Phone;
Q Matsushita;
Q Mitsubishi;
'Q Motorola, Inc.;
Q NEC;
Q Nokia;
Q NTT DoCoMo;
a Palm;
Q Research In Motion;
Q Samsung;
Q Sharp;
Q Siemens;
Q Sony;
Q Sun Microsystems, Inc.;
Q Symbian;
, Q Telcordia Technologies.
MIDP
:
Q 96x54
1 ;
Q ;
Q 32 ;
Q 128 MIDP;
Q 8 ;
Q ;
Q .

Java 2 Micro Edition


CLDC/MIDP .
MIDP : MIDP 1.0 MIDP 2.0.
MIDP . , Java,
MIDP 1.O. Java 2 ME
API.
MIDP 2.0 ,
.
, MIDP 1.0.
MIDP 2.0 , MIDP 1.0,
MIDP 2.0, MIDP 1.0.
MIDP 1.0, MIDP 2.0
. .

, : ,
,
" , .

. Java Java, .
, " ,
.
, Java
Java

, Java ,

Java. . 2.2 HIDP 2.0


.
MIDP 1.0
' Java 2 ME
CLDC
-

. , DirectX 9.
"
C++,
KVM
Java
Di
rectX Java 2 ME.


2.2.

MIDP CLDC
MIDP 2.0/CLDC 1.0. .

2.4. MIDP 2.0


CLDC 1.0
Java ,
, , . ,
Java, , . ,
, "
, .
MIDP2.0 , CLDC 1.0,
, , , .
Java 2 SE ,
Java 2 ME. MIDP 2.0 CLDC 1.0, .
.
Q java.lang;
D java.util;
1
java.io;
javax.microedition.lcdui;
Q javax.microedition.lcdui.game;
Q javax.microedition.io;
Q javax.microedition.media;
Q javaximicroedition.media.control;
Q javax.microedition.pki;
Q javax.microedition.midlet;
Q javax.microedition.rms.
javax.microedition.*, Java
2 ME MIDP 2.0. Java.*, Java 2 SE
1.4, , CLDC 1.0.

2.4.1 java.lang
Java .
Runnable. . 2.3 java.lang.
java.lang .
:
Runnable - .

Java 2 Micro Edition


1

Boolean

Character

StringBuffer

Short
Runtime

String

Thread

System

Throwable

Exception

Error
,

-r-t

h-

>

<

>

0.

- 1

11

CQ

13

' -

)
1-

t-H

:
0

3s

Exception

Exceptior

oundsExce

RuntimeException

oundsExce

Exceptio

ntExcepti

-1

.xception

ateExcepl

Out DfMpmnrv Frro

InstantiationException

dsExcept

ClassNotFoundException

InterruptedException

tateExcep

IllegalAc6essException

izeExcept

VirtualMachineError

xception

'

Hath
Long

Class

Byte

Integer

\_
i-

2.3. java.lang
:
Q Boolean - - , , Boolean;
Q Byte - - Byte;
Character - - Char;
C l a s s - ,
Java;
Q Integer - - int;
Long - - , ;
Q Math - , ;
Q Object - Java.
Obj ect ;
Q Runtime - ;
Q Short - - ,
Short; .
Q String ;
S t r i n g B u f f e r - ;

MIDP CLDC
System - ;
Thread - ;
Throwable - , .
:
Exceptions - ;
Q ArithmeticException - ;
Q Ar ray IndexOutOf Bounds Except ion -
;
Q ArrayStoreException - i
;
Q ClassCastException - ;
Q ClassNotFoundException - ;
IllegalAccessException - ;
Q IllegalArgumentException - ;.
Q IllegalMonitorStateException - ;
Q IllegalStateException ;
IllegalThreadStateException ;
G IndexOutOf BoundsException - ;
Q InstantiationException - ;
Q interruptedException -
:
Q NegativeArraySizeException -
, ;
NumberFormatException - ;
Q RuntimeException - Java;
SecurityException - ;
Q StringlndexOutOf BoundsException -
.
:
Error. ;
Q OutOfMemoryError - ;
Q VirtualMachineError - .

2.4.2. Java, util



. Java 2 SE.
. 2.4 Java.util.
:
Q Enumeration - .

Java 2 Micro Edition

EnptyStackException

NoSuchElement Exception

2. 4. Java, util
:
Calendar - ;
Q Date - ;
Q Hashtable -
;
Q Random - ;
Stack - ;
Q Timer ;
Ul TimerTask - ;
Time Zone - ;
V e c t o r - .
.
:
G Empty StackExcept ion - ;
Q NoSuchElementException - .

2.4.3. Java, io

. . 2.5 java.io.
:
Q Datalnput
;
Q DataOutput - .
:
. Q ByteArraylnputStream -
, ;

MIDP CLDC
Object

ByteArraylnputstream

E
CO
CO

Q.

HH
CO

H
0

l
InputStream
i _t_ 1

OutputStream

Reader

I-

E
cd

u
H
CO
H
3
ex
+-*

>.

s
cd
O>
-H
CO
M

CL
H

cd

OJ

4->

cd

>4

4->

i
i

lOException

-M
CO

cd

CD

i
Writer

InputStreamReader Exception OutputStrearaWriter

CO
l_
l_

1
Throwable

4-

cz

EOFException

a.

UnsupportedEncodingExceptior

InterruptedloException
JTSOataFormatException

2.5. Java.io
Q ByteArrayOutputStream - ;
Q DatalnputStream-
Datalnput, ;
DataOutputStream - DataOutput, ;
Q InputStream - , ;
Q InputStreamReader Reader,
;
Q OutputStream - , ;
,
Q OutputStreamWriter - Writer,
;
PrintStream - ;
Q Reader - ,
;
Q W r i t e r - ,
.
:
Q EOFException - ;
Q InterruptedloException -
;
Q lOException - ;
Q UnsupportedEncodingException - ;
Q UTFDataFormatException - UTF-8.

Java 2 Micro Edition


2.4.4. javax. microedition. io
. . 2,6 . 2.7
javax.microedition.io.
:
Q CommConnection - ;
Q Connection - ;
Connection

l-t

CD

-'

CD

.
-

CD

0
0

ex

- -

0
0_
0

CD

0)

:
=

0
0

:
:

CD

cz

.
3=

Datagram

Datagram

Datalnput DataOutput Securitylnfo

t
:

CD

cz

2.6. javax.microedition.io

PushRegistry

Thorwable

ConneotionNotFoundExoeption
2.7. javax.microedition.io

MIDP CLDC
Q
Q
G

ContentConnection - ;
Datagram - ;
DatagramConnection - ;
HttpConnection - http-;
HttpsCo,nnection -
http-;
Q InputConnection - ;
Q OutputCpnnection - ;
Q SecureConnection - ;
Q Securitylnf - ;
Q ServerSocketConnection - ;
Q SocketConnection - socket () ;
Q StreamConnection' ;
Q StreamConnectionNotif ier - ;
Q UDPDatagramConnection .
:
Q Connector - ;
PushRegistry - .
:
ConnectionNotFoundException .

2.4.5. javax.microedition.lcdui
.
, . . 2.8 javax.microedition.lcdui.
:
Choice ;
Object

Command

Display

Displayable
,

Font

,' '

Canvas Screen

*.

Alert Form

List

TextBox

Graphics
i

!->

+J
CO
=3

Image

Item
Imageltem U

Gauge

DateField -

1
AlertType

ihoiceGroup

2:8. javax.microedition.lcdui

Ticker
i
s

*'
(

td
OL
CO

9
l->
HI

Dl

CO

i
T3

1 t
9
-r4

U.
H
X
CD
1

Java 2 Micro Edition


CommandListener - ;
ItemCommandListener -
Item;
. ItemStateListener - Item Form.
:
G Alert
;
Q AlertType ;
Q Canvas - , ;
Q ChoiceGro.up - . Form, Item
Choice;
Q Command - , ,
, ;
Cusfcomltem-
Form;
DateField . Form, Item;
Display - -, ;
Q Displayable - , ; .
Q Font - ;
Q Form - ,
;
Q Gauge - ;
Q Graphics - ;
Q Image - , PNG;
D Imageltem ;
Q Item - , Form;
Q List - ;
Q Screen - "
;
Q Spacer - ;
Stringltem - ;
*
Q Text Box - ;
Q TextField- ,
Form;
Q Ticker - .

MIDP CLDC

2.4.6. javax.microedition.lcdui.game
MIDP 2.O. ,
. . 2.9
javax.microedition.lcdui.game.
:
Q GameCanvas
,
;
Q Layer - ,
;
Q LayerManager -
;
2.9.
Sprite - ;
TiledLayer ,.

2.4.7. javax.microedition.media
MIDP 2.0 .
(MMAPI Expert Group), :
Nokia (Specification Lead);
Q Aplix Corporation;
Beatnik, Inc.;
France Telecom;
Insignia Solutions;
Q Mitsubishi Electric Corp.;
LJ Motorola;
Q Netdecisions Holdings United;
Q NTT DoCoMo, Inc.;
Openwave Systems Inc.;
Q PacketVideo Corporation;
Q Philips;
a Siemens AG ICM MP TI;
Q Smart fusion;
Sun Microsystems, Inc.;
Q SymbianLtd;
Q Texas Instruments Inc.;
Q Vodafone;
Q Yamaha Corporation;
Q Zucotto Wireless.
-

Java 2 Micro Edition


MIDP 1.0
,, Manager
Throwable .
. MIDP 2.0
'
.
javax.microediException
tion.media. . 2.10 .
:
Q Control - 2.10.
;

Q" C o n t r o l l a b l e -
javax.microedition.media.
;
Player - ;
Q PlayerListener -
.
:
Q Manager - .
:
Q MediaException - - .

2.4.8. javax. microedition. media, control


javox.microedition.media.control
. ,
,
ToneControl
VolumeControl
. 2.11 2.11.
.

:
javax. microedition. media.control
' Q ToneControl - ;
Q VolumeControl - .

2.4.9. javax. microedition. midlet


, Java 2 ME. (MIDP). 2.12 javox.microedition.midlet.
:
I
MIDlet - , MIDlet,
.
'

MIDP CLDC
:
MIDletStateChangeException -
MI Diet.

2.4.10. javax.microedition.pki
javax.microedition.pki
. 2.13 .
:
C e r t i f i c a t e - .
:
Certif icateExcepti.cf- , .
Object

_L

HIDlet
\

Throwable

Throwable

Exception

Exception

lOException

MIDletStateChangeException

t
CertificateException

2.12:

javax.microedition. midlet

2.13.

javax.microedition. pki

2.4.11. javax.microedition. rms



.
(Record Management System), , , ,
. . . 2.14
javax.microedition.rms.
:
Q RecordComparator ;
Q RecordEnumeration - ;
Q RecordFilter - ;
Q RecordListener - .
:
RecordStore - .

Java 2 Micro Edition

RecordStore

Throwable

RecordStoreNotFoundExceptior
RecordStoreFullException RecordStoreNotOpenException
2.14. javax.microedition.rms
:
Q invalidRecordlDException - ;
RecordStoreException ;
Q RecordStoreFullException-
;
RecordStoreNotFoundException - ,
;
Q RecordStoreNotOpenException - .
, , .
2, Java 2 ME,
CDLC/MIDP.

, Sun Microsystems.

3.

Java 2
ME,
- SUN ONE Studio 4 Mobile
Edition J2ME Wireless Toolkit 2.1. Sun Microsystems.
, - ,
\SDK . , ,
, .
SUN ONE Studio 4 Mobile Edition
J2ME Wireless Toolkit 2.1,
Java 2 SDK, SE vl.4.2_03 (Software Development Toolkit Standard Edition). ,
Java. Java 2 Runtime Environment, SE vl.4.2_03, Java.

3.1. Java 2 SDK SE


j2sdk-l_4_2_03-windowsi586-p \SDK, , '
. ,
Next, Java 2 SDK SE vl.4.2_03 - Custom Setup, . 3.1.
. , Next.
Java, ,
, . Java 2 SDK, SUN ONE Studio 4 Mobile
Edition J2ME Wireless Toolkit.

. ,
, SUN ONE Studio 4 Mobile Edition, J2ME
Wireless Toolkit 1.0.4 01, J2ME Wireless

Custom Setup
Select the program features you want installed.
Select optional features to install from the list below. You can change your choice of features after
installation by using the Add/Remove Programs utility in the Control Panel
Feature Description ;

;g^|T

Demos

The Java 2 SDK, SE vl.4.2_03,


including private j2rel.4.2jTO.
This will require 120 MB on your,
hard drive.

Source Code t
Public Java Runtime Environment

Install to:
C:y2sdkl.4.2JD3\

Change..

<Back

Next >

Cancel

. .7. Java 2 SDK, SE v1.4.2_03-Custom Setup


Toolkit 2.1. , .
SUN ONE Studio 4 Mobile Edition.

3.2.
SUN ONE Studio 4 Mobile Edition
- \SDK ffj_me_win32 -
SUN ONE Studio 4
Mobile Edition. ,
, Next, .
Next, SUN ONE Studio 4 update 1,
Mobile Edition Setup, . 3.2.
,
, , , . 3.3, .
, SUN ONE Studio 4 Mobile Edition
.
.
. 3.3 J2ME Wireless Toolkit, Java 2 Platform
Micro Edition, \SDK ( ).

SUN ONE Studio 4 Mobile Edition


* Sun ONE Studio 4 update 1, Mobile Edition Setup
The installer has selected the following versions of the Java 2 SDK that can be used
with the IDE. The recommended option is the Java 2 SDK, Standard Edition (J2SE
SDK), v. 1.4.0 with the IDE. Choose from the versions of J2SE SDK listed below or
click Browse to specify a different J2SE SDK, v. 1.3.1 or v. 1.4.0. Refer to the Getting
Started Guide for instructions on installing the J2SE, v. 1.4.0 platform.

Sun ONE
Studio

Java 2 SDK Home: C:\j2sdk1.4.2_03


List of Java 2 SDK versions (v. 1.3.1 andv. 1.4.0)
C:tj2sdM.4.2_03 (v. 1.4.2_03)

< Back

Next >

Cancel

. .2. SUN ONE Studio 4 update 1, Mobile Edition Setup

'* Sun ONE Studio 4

on Setup
Select the components ofSun ONE Studio 4 update 1 that you want to install. Some
components cannot be deselected if they are required by other components that are
selected to be installed.
/ Core Platform & Modules

Sun-ONE
Studio

,/ Java 2 Platform Micro Edition (J2ME), Wireless Toolkit 10.4

Denotes that the component cannot be deselected and


will be installed.

Back

Nexf>

. 3.3.

]]

Cancel


, Next SUN ONE Studio 4 Mobile Edition .

3.2.1. SUN ONE Studio 4 Mobile Edition


SUN ONE Studio 4 Mobile Edition,
. SUN ONE Studio 4 Mobile Edition,
. , . 3.4
, , Enter User Directory

Type the name of the directory where you want thetDE to store your
.
settings and project information. For example, type CAide-userdir.

Be sure that the directory you choose is in a place that is always
accessible on your system. If you have different versions of the IDE,

,
use a different user directory for each IDE versioa

Next. The name of this directory is stored in your Microsoft Windows


Registry and is used every time you run the IDE. This directory

. 3.5,
should be different than the directory where the IDE is installed.

|C:VJavaSourcesj
.

SUN ONE Studio,
, . .4.
, Finish. -

need to import settings;


; lets you impott your iPc environment and settings from previous (serge-user mode) versions;
NetBean* (3.0 and 3.1 releases)
' '. ;
Forte tor Java (2 0 and 3 0 releases)
If your previous was installed n multi-user mode, cfick Cancel end see the'Sun ONE Studio Knowledge [3ase
Do you wish to import settings from a previous arstaSaticn?
!

j tip. Skip the settings import.: '.

.' .

: Yes, please import my settings from the previous version


fete: t is not possbte to import settings at a later ttn

. .5. Setting Import Wizard

SUN ONE Studio 4 Mobile Edition


, . 3.6, .

. 3.6. Setup Wizard


Setup Wizard . , , . 3.6,
, web-, (Proxy Server). Next. . 3.7, .

, Next, Update
Center, . 3.8, .
,
, . Finish. SUN
ONE Studio 4 Mobile Edition, Registration Wizard,
. 3.9.
.
,
, '. -

Modules
S>

Backward Compatibility
Data Files
Debugging
Distributed Application Support
Editing

General Online Help

Infrastructure
J2ME

. .7.

s Update Center
i.J MetBeans Update_Ceriter Beta
] 'NetBeans Update eerier Alpha

13'BunONE"studio''''-

. .8. Update Center

SUN ONE Studio 4 Mobile Edition, Welcome SUN ONE Studio 4 update 1, Mobile Edition, . 3.10,, .

111

SUN ONE Studio 4 Mobile Edition


noose to Create or edit Registration
Registering the product wiH allow .

> -.ibout new products icf product

Register usirjg the web c change regatrawn - necessary after swtehmglDc versions]
Highfy recommended it pr^wtei there irjditwnal benefits'
rnodufes andi^dales.
'
- - - . - . : . . .-.:>
of Sun Sti-, preview fitodiJes, patches and bug fixes through Ihe Early

- EntStemerits to
Access progr

Register by Fax or maS (fil cud ^ t.:-c i'n and pt :nt it, !he:i Fax or
. Register Later

'-

. - '

',.:. Never Pegi^Jer

Serial Nuieer: <tv> set Is reoufreti by ilns prociuci

. .9. Registration Wizard

I Welcome to Sun ONE Studio 4 update 1, Mobile Edition

To get started, choose a task below.


Sun Ore Studio Web Resources

Create a new Forte object, for example:


A MIDlet

Si Open File... :

A MIDlet Suite
A Java Class
Or, select from the complete set of object templates.

Tip of the Day


S Next Tip
^ Previous Tip

You can also update modules in the IDE without having to connect
to an Update Center server. Manually download the NBM file of the
module you want to update. Then choose Tools > Update Center and
select the Install Manually Downloaded Modules radio button in the
fit-et r,yno r,f tKa tln-yatvl

Show Welcome Screen on Startup

. 3.10. Welcome SUN ONE Studio 4 update 1, Mobile Edition

j
Welcome
, .
.
SUN ONE Studio 4
Mobile Edition.
, SUN ONE Studio 4 Mobile Edition, . 3.11.

.le

Ed* vtew

:! :...,

v-^.-r-*v)

xtf

vwxtow Help

ii *' . :t

. 3.11. SUN ONE Studio 4 Mobile Edition


'
,
, , , , ' Explorer
(), SUN
ONE Studio 4 Mobile Edition. Explorer :
, Javadoc. Explorer.
, , , ,
. Archive (JAR, Zip), 3.2.2.
.

SUN ONE Studio 4 Mobile Edition


Javadoc
HTML .
, SUN ONE Studio 4
Mobile Edition, . , , . .
SUN ONE Studio 4 Mobile Edition.
-
.

File
New (Ctrl+N) - .
U Mount Filesystem - 1.
Uniriount Filesystem - .
Q Open File (Ctrl+O) - .
Q Save (Ctrl+S) - . ,
Q. Save All - .
Q Print (Ctrl+P) - .
Q Page Setup - .
Q Exit - SUN ONE Studio 4 Mobile Edition.

Edit
Q
Q
Q

Q
Q
Q

Undo (Ctrl+Z) - .
Redo (Ctrl+Y) - .
Cut (Ctrl+X) - , .
(Ctrl+C) - .
Paste (Ctrl+V) - .
Delete (Delete) - .
Find (Ctrl+F) - .
Replace (Ctrl+H) - .
Search Filesystem - .

View
Q Explore From Here (Ctrl+O) -
.
Q Properties (Ctrl+1) - .
Q Explorer (Ctrl+2) - .
Q Source Editor (Ctrl+3) - .
Q Output Window (Ctrl+4) - ,
.
Debugger Window (Ctrl+5) - .
Q Web Browser (Ctrl+7) - -.
Javadoc Index Search (Shift+Fl) - .
Workspaces - .


Project
Project Manager (Ctrl+Shift+F9) - .
Compile Project (Ctrl+Shift+Fll) - .
Build Project (Ctrl+Shift+Fll) - .
Set Project Main Class (Ctrl+Shift+M) -
.
Q Debug Project (Ctrl+Shift+F5) - .
Q Import Project - .
Build
Compile (F9) - .
Q Compile All (Shift+F9) - .
Q Build (F11) - .
Q Build All (Shift+Fl 1) - .
Stop Compile (Alt+Shift+C) .
Q Next Error (Fl2) - .
G Previous Error (Shift+F12) - .
Debug
Q Start (Alt+F5) - .
Q Finish (Shift+F5) - .
U Add Breakpoint (Ctrl+Shift+F8) - .
Q Debugger Window (Ctrl+F5) - .
Help
Q Contents - .
U - .

3.2.2.
SUN ONE Studio 4 Mobile Edition
SUN ONE Studio 4 Mobile Edition,
Project => Project Manager, . 3.12, New.

Create New Project, Project Name ,
Demo .
. 3.13.
: Java 2 Standard Edition
(J2SE) Mobile Information Device Profile (CLDC\MIDP),
. Java 2 SE, Mobile Infdrmation Device
Profile (CLDC\MIDP).

SUN ONE Studio 4 Mobile Edition

Project Configuration {1 of 1)
Choose a configuration for. this project
J Java JL Standard Edition (JISE) : ..
> Mobile Information Device Profile (CLQCAVD-'i
The project configuration win affect the default con
and code completion .for Java sources.'

. 3.12.

Project Configuration (1 of 1)

Choose a configuration for thi? project.


Java 2 Standard Edition (J2SE)
Mobile Information Device Profile (CLLICWDP).
The project configiiralion witl afiocf !he >: fault "ornpiler. executor, debugger,
and code completion for Java sources.

":

. 3.13.


Finish.
Explorer,
, Javadoc,
Project
Local Drectory
Demo.
! 3 Archive (JAR, Zip)
. Explorer,
.

, Mount => Archive
(JAR, Zip), . 3.14.
Archive (JAR, Zip),
New Wizard Archive (JAR, Zip),
. 14.


Java API. ,
MIDP 1.0, midpapi.zip. . SUN ONE Studio 4 Mobile
Edition J2ME Wireless Toolkit 1.0.4 01,
API MIDP 1.0. . 3.15 New Wizard 1 Explorer [ ] ;

. 3.15, New Wizard - Archive (JAR, Zip,)

'

SUN ONE Studio 4 Mobile Edition


Archive (JAR, Zip) API, lib
J2ME Wireless Toolkit 1:0.
API MIDP 2.0,
, J2ME Wireless Toolkit 2.1 . API, , ,
.
.
, , . . , ,
Mount => Local Directory New Wizard - Local Directory , , Finish.
, .
Explorer Tools => Add to
Project. ,
3.2.2.

3.2.3.
SUN ONE Studio 4 Mobile Edition
, . Demo, Explorer
File => New File, Ctrl+N. New Wizard, . 3.16,
.

HelloMIDlet, ,
Java 2 ME , . 5
. Next,
New Wizard - HelloMIDlet, , , . . 3.17 New Wizard
HelloMIDlet .
, Finish.
HelloMIDlet Demo, Source Editor, -

Executable class which displays text on the screen of a device,

. 3.16. New Wizard

. 3.17. New Wizard - HelloMIDIet


SUN ONE /
Studio 4 Mobile Edition, . 3.18.
Source Editor, , .

SUN ONE Studio 4 Mobile Edition


& Vfew Project Bw Debug Versiorcng Tools

V*daw Help

javax.tticcoedmon.Kidlet.*;
uit>ort Javax.aictoedition.Icdm.*;

lie claM HelloHIDlet extewta HIDlet inploexta CouandLlaunec |


privttte Coesand exicCoMMand; ,

public
display - Display
sxitCommand new C<eM*df"Exit", .SCREEN, 2);

. 3.18. Demo

3.2.4.
SUN ONE Studio 4 Mobile Edition

'


HelloMIDlet
Test string. .
Build => Compile F9. ,
Build =>
Build F11.
SUN ONE Studio 4 Mobile Edition.
Debug = Start Alt+F5.
. 3.19.
, SUN ONE Studio 4 Mobile
Edition, J2ME Wireless
Toolkit 1.0. :
DefaultColorPhone - ;
Q DefaultGrayPhone - ;
Q MinimumPhone - ;


G Motorola_i85s - i85s Motorola;
Q PalmOS_Device - Palm;
Q RIMJavaHandheld - Blackberry.

,
Explorer, Device
Emulator Registry, ,
. 3.20.
i Explorer [] ;
^
* Processes
Debugger
S& vcs Commands
> Device Emulator Registry
9 Default Emulators
> MIDP : J2ME Wireless Toolkit 1 .0.4,01
9
Installed Emulators
J2MEVWeless Toolkit 1 .0.4JJ1
\ 0 DefaultColorPhone
] 0 DefauJGrayPhone
jy MinimumPhone

PalmOS_Device
RIMJavaHandheld

. 3.20.
Explorer

. 3.19. ,

HelloMIDIet

,
Installed Emulators Device Emulator Registry,
. Installed Emulators, J2ME Wireless Toolkit 1.0,
. J2ME
Wireless Toolkit 1.0, , Motorola_i85s Set As
Default, . , ,
Debug => Start
Alt+F5. . 3.21 i85s Motorola.
,

J2ME Wireless Toolkit 2.1


. 3.21. i85s
SUN ONE Studio 4 Mobile Edition.
Explorer
Device Emulator Registry

Installed Emulators. Add emulators.
Select emulator installation directory, ,
, Add.
SUN ONE Studio 4
Mobile Edition ,
,
SUN ONE Studio 4 Mobile Edition .
,
SUN ONE Studio 4 Mobile Edition.

3.3.
J2ME Wireless Toolkit 2.1
J2ME Wireless Toolkit 2.1 Sun Microsystems
. J2ME Wireless Toolkit 2.1 : ,
J2ME Wireless Toolkit 2.1 . . .

3.3.1. J2ME Wireless Toolkit 2.1


- \SDK j2me_wireless_toolkit-2_lwindows.
/2 Wireless Toolkit. Java Virtual Machine Location, . 3.22, , Java .
Java 2 SDK SE,
, , Java Virtual Machine Location Next. Choose Destination Location, . 3.23, J2ME Wireless Toolkit 2.1.

The Java 2 SDK, Standard Edition (1.4 or later) '


is instated on jiout machine at CA|2sdk1.4.2 03.
Press 'Next' to install J2ME Wireless Toolkit 21 with this Java 2 SDK.
or Browse' to locate another Java 2 SDK.

Destination Folder Browse.

C:\j2sdk1.4:2J>3

< Back

Next>

Cancel

. 3.22.
Java Virtual Machine Location

Choose Destination Location


Select folder where Setup will install files.
Setup will install J2ME Wireless Toolkit 21 in the following folder.
To install to this folder, dick Next. To install to a different folder, click Browse and select
another folder.

r Destination Folder Browse...

C:\WTK21

Back

Next>

Cancel

. 3.23. Choose Destination Location


, , ,
.
Next Choose Destination Location,
J2ME Wireless Toolkit 2.1.

J2ME Wireless Toolkit 2.1


, => =>
J2ME Wireless Toolkit 2.1 => KToolbar
J2ME Wireless Toolkit, . 3.24,
.

-IIIIX1

4 J2ME Wireless Toolkit


ct

File J^J^
Help
i % New Project... ^ Open Project

^ Clear Console

i Device:
Create a new project or open an existing one

. 3.24. J2ME Wireless toolkit


J2ME Wireless Toolkit, , . ,
.
File
Q New Project - ;
Open Project ;
Q Save Console - ;
Q Utilities - ;
Exit - .
Edit
l_l Preferences - ;
Q Clear Console - .


Project
Q
Q
Q
Q
Q
Q

Build ;
Clean - ;
Run - ;
Package - -;
Debug - ;
Settings - .

3.3.2. J2ME Wireless Toolkit 2.1


J2ME Wireless Toolkit, SUN
ONE Studio 4 Mobile Edition.
New Project, File => New
Project. New Project, . 3.25, Project Name , Demo MIDlet Class Name,
.

. 3.25. New Project


, , , : Java 2
ME - ,
. MIDlet Class Name
, ,
. 5, Java 2 ME. SUN ONE Studio 4 Mobile Edition,
Demo, HelloMIDlet;
HelloMIDlet MIDlet
Class-Name, Create Project.
Settings for project Demo, . 3.26,
.
Settings for project Demo ,
. API Selection, . 3.26, .
: -
MIDP 1.0, Target Platform ( ), .

J2ME Wireless Toolkit 2.1


j Settings for project "Demo"
API Selection I Required J Optional J User Defined f MIDIets | Push Registry I Permissions;
Target Platform

JJTW

J7WI

: JTW

Custgm
^3

rProfiles
MIDP2.0

Configurations
CLDC1.0
CLDC 1.1
.Optional

Wireless Messaging API (JSR120)


0 Mobile Media API (JSR 135)

.-Additional APIs

Web Service Access for J2M (JSR 172).

. 3.26. Settings for project Demo


Required (), . 3.27,
, .
Q MIDlet -Jar Size - ;
Q MIDlet -Jar - URL - ;
Q MIDlet - Name - ;
Q MIDlet - Vendor - ;
Q MIDlet - Version - ;
,Q MicroEdition - Configuration - ;
Q MicroEdition - Profile - .
JAD .

Settings J2ME Wireless Toolkit 2.1. JAD JAR 3.4. ,

. , Settings for project Demo>> Demo.

Optional 8 User Defined ! MIDIets ,j Push Registry j| Permissions

. 3.27. Required
J2ME Wireless Toolkit 2.1, ,
. J2ME Wireless Toolkit 2.1. ?
, , Settings for project Demo , Demo.
J2ME Wireless Toolkit 2.1 :
Creating project "Demo"
Place Java source f i l e s in " C : \ W T K 2 l ^ a p p s \ D e m o \ s r c "
Place application resource f i l e s in
"C:\WTK21\apps\Demo\res"
Place application library f i l e s in
"C:\WTK21\apps\Demo\lib"

, (, , *.java), C:\WTK21\apps\Demo\src.
, ,

J2ME Wireless Toolkit 2.1


C:\WTK21\apps\Demo\res; ,
C:\WTK21\apps\Demo\lib. , , : C:\WTK21\apps\Demo\src.
, . Demo,
:
Q bin - : jar, jad .
3.4,
;
Q classes - ;
tmpclasses - ;
Q tmplib - .

3.3.3.
J2ME Wireless Toolkit 2.1
Demo, SUN ONE Studio 4 Mobile Edition 3.2.3.
:!111 Demo ,
SUN ONE Studio 4 Mobile Edition
HelloMIDlet \Code\ HelloMIDlet, C:\WTK21\apps\Demo\src. Build . J2ME
Wireless Toolkit 2.1, :
/
Building "Demo"
Build complete
, , , , -
. , Run,
DefaultColorPhone,
J2ME Wireless Toolkit 2.1 . 3.28.
,
Select Launch, , Test string. Exit . ,
J2ME Wireless Toolkit 2.1,
:
Running with storage root DefaultColorPhone
Execution completed.
. 3.28. DefaultColorPhone

! i
4 9 3 0 8 4 bytecodes executed
57 thread switches
487 classes in the system (including system c l a s s e s )
2 8 4 4 dynamic o b j e c t s allocated ( 9 2 0 6 8 'bytes)
2 garbage collections ( 6 1 9 7 6 bytes collected)
, .
,
Device J2ME Wireless Toolkit 2.1,
' . J2ME Wireless Toolkit 2.1 :
Q DefaultColorPhone " ;
Q DefaultGrayPhone - ;
MinimumPhone - ;
Q MediaControlSkin
;
Q QwertyDevice - .
, , .

3.4.
- , : JAD- . Sun ONE
Studio; , . J2ME Wireless Toolkit, JAD-
\bin .
3.2,3 3.3.2 Demo,
HelloMIDlet. : Demo.jad MANIFEST.MF.

3.4.1.
MANIFEST.MF . HelloMIDlet ,
:
MIDlet-1: Demo, Demo.png, HelloMIDlet
MIDlet-Name: Demo
MIDlet-Vendor: Unknown
MIDlet-Version: 1.0
MicroEditicri-Conf i g u r a t i o n : CLDC-1. 0
M i C r o E d i t i o n - P r o f i l e : MIDP-1.0


.
J2ME Wireless Toolkit 3.3.2
Settings for project Demo . 3.26, , .
Settings for project Demo, ,
^-.

3.4.2. JAD
, Demo
Demo.jad. JAD-
ava
G Application Descriptor). , , .
.
Demo Demo.jad, . Demo.jad,
, .
, JAD-
. JAD-.
Demo.jad
:
MIDlet-1: Demo, Demo.png, HelloMIDlet
MIDlet-Jar-Size: 30
MI.Dlet-Jar-URL: Demo, jar
MIDlet-Name: Demo
MIDlet-Vendor: Unknown
MID.let-Version: 1.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-1.0
JAD-
MANIFEST.MF. Java 2 ME, JAD - . JAD,
. , . ,
. , JAR-, Java (
).


3.4.3. JAR
Java
*.jar. JAR - ,
. JAR-
zip-, . 'rpaMto Java , , . -
.
, Java ,
30 80 .
. 40-50 . , JAR-. jar-. HelloMIDlet Demo
JAR-.
Sun ONE Studio 4 Mobile Edition JAR-
.
J2ME Wireless Toolkit 2.1 . J2ME
Wireless Toolkit Project => Package => Create Package. , JAR-. Demo \ Demo.jar.
Demo Demo.jar.
, zip-, WinRar WinZip Demo.jar. HelloMIDlet.class META-INF,
MANIFEST.MF.
?
JAR-, ( ) JAR-, . -.
HelloMIDlet ,
, JAR-.
MANIFEST.MF META-INF.

JAR JAD
. ,
Java 2 ME, . JAR
, JAD JAR-.

lllllHHH

JAD , JAD Java . - Siemens. J -, ,


- , .

4.


. , , .
SDK (Software Developer
Kit) .
Nokia.
.
, , . -
, , . ,
:
Q ;
Q Java 2 ME C++;
Q ;
Q .
,
, .
Java 2 ME, MIDP 2.0 MIDP 1.0,
, Java , . , ,
, ,
.
, , , . SDK
, .

Sun Microsystems Borland,
.
Java 2 ME.

Nokia
, ,
. Java 2 ME
. ,
,
DefaultColorPhone ( ) Sun, 3. , ,

.
. ,
.
-, ,
,
. . . Nokia, Siemens, Sony Ericsson, Motorola Samsung. 3.
, ,
.

4.1.
Nokia
Nokia , , . -!
, Nokia: http: //forum.nokia.com. , - Nokia , ,
. , , Registration, , . 4.1.
,
. ,
, . ,
.
.
, . 4.1, e-mail . , , ,
, , . , -


Developer Home: Registration: Registration
CONNECTING PEOPLE

to Forum Nokia

Forum Nokia is a vital resource to the mobile development community,


with a current membership of more than one million developers who
count on the site to keep updated on the latest tools, tips, insights, and
Industry trends.

All ll.ld. <l. requited.

jSearch Forum Nokia


Help Advanced

(Vearoh)

m Newsletters
Developer Platforms

Registration is free and protected by our strict privacy policy.


User Name and Password

FORUM
NOKIA

Series 40
Series 30

User name:'
For CDMA Market

Password (mm e chjrjcten?

Forum Nokia PRO

Confirm password; *

Resources
Books

E-mal address: *
Yes. pit* contact me via -mail rgjldin0 Forum Nokia updates
I Next I

[ Cancel I

Device Specifications
Porting
Device Optimization

. 4.1.
, .
, ,
. ,
Nokia N-Gage QD ().

, q Nokia.
, , e-inail, .
. Nokia: http://
forum.nokia.com, .
Tools&SDK ,
. ,
Nokia Developer's Suite 2.0 for J2ME, , . 4.2.
, ( 1
, ),
. , Download now,
Serial number for this product, . . Nokia \Nokia:

Nokia |
FORUM

Developer Home: Resources: Tools & SDKs: Tools Detail


~

NOKIA

Nokia Developer's Sidle 2.0 for J2ME


The NoKia Developer's Suite for the Java 2 Platform.
Micro Edition. Version 2.0 for Windows provides
developers with class libraries, APIs, and Nokia
device emulators used to create mobile Java
applications targeted to Mobile Information Device
Profile (MIOP) 1.0 and MIDP 2.0. The tool can also be
integrated with major Java application-specific IDE
tools such as Borland JBullder and Sun ONE Mobile
Edition. Developers can create MiDlets based on the
MIDP 1.0 specification that will successfully
Implement on Series 30, Series 40, and Series 60
NoMa devices, Including the Nokia 631 Ol, Nokia
351 Ol, NoMa 7210. and NoMa 3650 mobile phones.
Use the Series 60 MIDP Concept SDK Beta 0.3, NoMa
edition to develop MIDIets which are based on the
MIDP 2.0 specification.

Developer
Platform

idded:

Developer
Platform

Developer
Platform

OS.Jun-03

} Requirements:
: Window* 2000 SP2. Windows XP SP1. or Red
i Hat 7.2
| Jjirj'" Runtime Environment(JRE)1.4.1_02
i Ol Itttr

i 2WUBofRAU

40
Series 60
Series 80

i -100 MS ottieedwsp.ee

i -300 MHz or fjster Pentium-elm processor


i
(350 MHz recommended)
i -84.000 colors with 1024x768 resolution
i Keyboard jnd mouse

For CDMA Market


orum Nokia PRO

: Download version for

Key features:
Full development cycle when Integrated into Borland
JBuilder and Sun ONE Mobile Edition
Also works In stand-alone mode with
additional external tools
Support for MIDP 1.0 and MIDP 2.0
Provides the Series 60 MIDP Concept SDK
Beta 0.3, NoMa edition
Deploys on devices using IrDA, USB, and RS232 (available on Windows platforms)
Provides an FTP-upload capability, Including
WML deck file generation
Supports application signing with
public/private key model
Integrated Audio converter for MIDI and ring
tone XML files
Support for Series 30, Series 40, and Series
60 devices
IDEs supported:
Borland JBullder 8
'

||v*ldows(39M8)

\ [ Downtoadnowj

Device Specifications

I You can iqustirijl number Is during the


| irwtjlletion, procta.

ppjljpg

Suit* foi J2ME*4,


,
1
Suit fot J2y E
. ImUlltttoB Outdt

Device Optimization
Technologies
Communities

! User OuldXs):

Discussion Boards
Professional Support
it j friend jbout this tool

Testing

.4.2.
Q Nokia Developer's Suite 2.0 for J2ME;
* Q Series 40 Developer Platform 2.0 SDK;
Q Series 60 MIDP 2.1 SDK;
Q Series 90 MIDP 1.0 SDK;
Q Nokia 5100 SDK 1.0;
Q Nokia 3410 SDK 1.0;
a Nokia PC Suite 5.1.
Nokia
(Series Developer Platform): 40,60,80 90. , . , ,
:
Q 40 - ,
96x65, 128x128 128x160 ;

*,.':

Q 60 - 176x208 ;
Q 80 - 640x200 ;
90 - 640x320 .
, 40,
.
Java 2 ME, Java . 60, 80 90 Symbian Java, C++.
Symbian.
, . SDK , '
.
Nokia, Nokia Developer's Suite 2.0 for J2ME. .

4.1.1.
Nokia Developer's Suite 2.0 for J2ME
Nokia Developer's Suite 2.0 for
J2ME,
Nokia: http: //forum.nokia.com. - \Nokia, nds_jme_v_2_0.zip. . setup.exe
, . Welcome
. 4.3, .
Welcome : Forum Nokia
Username - Nokia Product Serial Number .
, , Forum Nokia Username
Next. forum.nokia.com,
. ,
Next Choose install set,
. 4.4.
Choose install set
Nokia Developer's Suite 2.0 for J2ME:
Standard installation.
- ;

Nokia
Nokia Developer's Suite 2.0 for JZME(TM)

You have selected a Nokia developer product to be installed.


You have the following installation options:
- If you are already a member of Forum Nokia and you have a serial
number for this product, please fill in the text fields below and then
press the "Next'button
- If you are not a member of Forum Nokia or do not have a serial
number for this product, please leave the text fields below empty and
then press the "Next" button

Forum Nokia Username:


Product Serial Number:
[ InstallAnywhere by Zero 0 Cancel

. 4.. Welcome
Nokia Developer's Suite 2.0 for J2ME

Standalone installation
Choosing this option will install Nokia Developer's Suite as
standalone product.

Integration with Borland JBuilder


Choosing this option will install Nokia Developer's Suite integrated
with Borland JBuilder IDE.

Integration with Sun(TM) ONE Studio


Choosing this option will install Nokia Developer's Suite integrated
with Sun Forte(TM) for Java(TM) IDE or Sun ONE Studio. Mobile
Edition.

. 4.4. Choose install set


Nokia Developer's Suite 2.0 for J2ME


Integration with Borland JBuilder. Nokia Developer's
-* Suite 2.0 for J2ME Borland
JBuilder;
Q Integration with Sun ONE Studio.
Sun ONE Studio.
, ,
Next. Standard installation
.
Sun Microsystems, Sun Microsystems. , Next Choose
install set, Select the installation directory of your Sun IDE,
. 4.5.

Please select the Installation directory of your Sun ONE Studio or


Sun Forte for Java.
The installer will automatically extend the Installation directory with
the required directories.

Please choose a directory:


C: Program Files\s1 studio Vne
Restore Defaut Directory

by Zero 0

. 4.5. Select the installation directory of your Sun IDE


, Please choose a directory
Sun ONE Studio 4 Mobile Edition
Next. ,
.
=> => Nokia Developer Tools => Nokia Developer's Suite2.0 for J2ME = Run

Nokia |
as a Standalone , Nokia Developer's
Suite2.0 for J2ME, . 4.6.
f... Nokia Developer's Suite for J2ME(TM)
Emulators

Tools

Help

Pi

Noki

uilfbihrtft lava? Pljri"fr\nri Mi*>*n

Create Class

Create
Application
- Package

Sign
Application
Package

Deployment

Start
Emulators

Messages:

Gear Messages

Audio Converter

NOKIA

. 4.6.
Nokia Developer's Suite for the Java 2 Platform, Micro Edition
.
.
:
Create Class - ;
Q Create Application Package - ;
Sign Application Package - ;
Q Deployment - ;


**.-*4i "*

Start Emulators - ; .
Q Audio Converter - - .
Start Emulators, , . 4.7.
NoMa Developer's Suite for JZME(TM)
File

Emulators

Tods

Help

"

Nokia Developer's Suite,fcrth;Java'"2 Platform, Micro Edition

i Application: C: WTK21 teppsDemoWn\Demo.jad

-.

Configure...

Create Class

Select Emutetors:
0 Nokia 721 0 SDK .0 <default>
0 Series 60 MDP Concept SDK Beta 0.3.1 , Nokia editor*

Create
Application
Package

Emulate

Sign
Application
Package

Deployment

Start
Emulators

Messages:

Clear Messages

Audio Converter

NOKIA

General )

. 4.7.
Nokia Developer's Suite2.0, - Nokia 7210
, .
, , Application, JAR-, Select Emulators, .
.
Emulate, . . 4.8

Nokia
4.8. Nokia 7210

Nokia 7210 Demo, 3 Test string.


Nokia Developer's Suite for the Java 2 Platform, Micro Edition, , Configure,
, ,
, .
Select language, ,
Emulators, - Add () Remove
().
Nokia Developer's Suite2.0 Sun ONE Studio Choose install 4.4, Sun ONE Studio 4 Mobile Edition,
. Sun ONE Studio 4
Mobile Edition . Tools => Nokia = Developer's Suite for
J2ME => Start Emulators, Start Emulators.
Application Select
Emulators Nokia.
Nokia Developer's Suite2.0 ,

SDK Nokia. SDK
- \Nokia ,
.
- \Nokia\Linux Nokia Developer's
Suite Linux .

4.1.2. Nokia PC Suite 5.1


\Nokia - Nokia PC Suite
5.1, .
Q Nokia Application Installer - Java 2ME Nokia;
Q Nokia Content Copier -
;
Nokia Image Converter - *.bmp, *.gif,
*.ipg, *.ipeg, *.png, *.otb, *.wbmp, Nokia;


Q Nokia PC Sync - ;
Q Nokia PC WAP Manager - WAP ;
Q Nokia Phone Browser -
Windows;
Nokia Phone Editor - ;
Q Nokia Sound Converter - MIDI
.
Nokia PC Suite 5.1 , .

4.7.5. Nokia
MIDP 1.0 ,
. Nokia .
Q com. nokia. mid. sound -
.
Q SounListener -
;
Q Sound - .
Q com. nokia. mid. ui - Java 2 ME;
Q DirectGraphics - ;
Q DeviceControl - ;
Q DirectUtils - ;
Q Full Canvas - .
.

4.2.
Siemens
Siemens , Java 2 ME. ,
Siemens www.siemens-mobile.com/developer. -
\Siemens, :
Q Siemens Mobility Toolkit for Java Development;
Q SMTK Emulator Pack for MC60;
a SMTK Emulator Pack for C60;
Q SMTK Emulator Pack for M55;

Siemens
SMTK Emulator Pack for M50;
SMTK Emulator Pack for S57;
,
Q SMTK Emulator Pack for S55;
.
a SMTK Emulator Pack for SL55;
a SMTK Emulator Pack for SL45;
SMTK Emulator Pack for C55; ,
SMTK Emulator Pack for 2128;
Siemens Date Suite.
Siemens Mobility Toolkit
for Java Development,
.

4.2.1. Siemens Mobility Toolkit


- \Siemens smtk_0_13_2_59,
,
Siemens Mobility Toolkit.
,
. ,
, .
Siemens, , Siemens Mobility
Toolkit. . 4.9 .

4.9. Siemens

, - \Siemens, Siemens Mobility Toolkit.


, : SMTK Emulator Launcher SMTK Manager.
SMTK Manager, , . 4.9.
SMTK Manager :
Select target emulator - , SMTK Emulator Launcher. -


<& SMTK Manaaer
Help
Select target emulator | SMTK management | Integration with IDEs |
Phone model
Siemens 2128
Siemens C55
Siemens C60 (Chinese!
<

Ai

Set target I

jsjj'
>'

Device info

Use the current target emulator for MIDIet execution


Quit

. 4,10. SMTK Manager


Device info
;
Q SMTK management - Remove
;
Q Integration with IDE's - Borland JBulder .
Siemens
SUN ONE Studio 4 Mobile Edition.
SUN ONE Studio 4 Mobile Edition
Explorer Device Emulator
=> Registry Installed Emulators", Add
emulators. Select emulator installation directory
,
Siemens. Siemens Mobility Toolkit
, 55, : C:\siemens\SMTK\emulators\M55.

SMTK Emulator Launcher. , . 4.11.
SMTK to Launcher,
.
(commands), . 4.12.
Commands ,

Start Java Application A* Emulator to Launch


Select phone model
Siemens 2128

Java . Siemens C55


Start Java Application, Siemens CSO (Chinese)
, JAR
Use the current target emulator
Cancel

. 4.11. SMTK to Launcher

Siemens
. 4.12. Commands

. , Nokia JAD ,
Siemens JAR . JAR-
.

4.2.2.
Siemens Date Suite

MSM: commands
MM: No Service
MM: Limited Service
MM: Full Service
Power: Begin Low Power
Power: End Low Power
SMS: Incoming Short Message
SMS: Immediate Message
SMS: Status Report
SMS: Toggle Voice Message
Switch Off
Change microedition.locale
Choose Network
Filesystem

\Siemens, -
Siemens Date
Suite , :
Q - SIM
;
Q SMS EMS - SMS EMS ;
Q -
;'
Q , : *.jpg, *.tif,
*.gif, *.bmp, ;
Q XTNDConnect PC Outlook Lotus Notes;
Q Data Exchange Software -
;
Q GPRS Modem Assistant - GPRS ,
.

4.2.2. Siemens
Siemens Java 2ME. :
Q com. Siemens .mp - .
Q MIDlet - MIDlet Java 2 ME.
com.Siemens.mp.color_game - .
Q GameCanvas - , ;
Q Layer - , ;
Q LayerManager - ;
Q Sprite - ;

'
Q
Q
G
Q

G
Q
Q
Q
Q
Q
Q

Q
Q

U
U

Q
Q

Q
Q
Q
G
Q

TiledLayer - .
com. Siemens . mp. game - ;
Extendedlmage - ;
GraphicObj ect Sprite TiledBackground;
GraphicObj ectManager - ;
Light ;
Melody - ;
MelodyComposer - ;
Sound - ; .
Sprite - ;
TiledBackground - ;
Vibrator - .
com. Siemens .mp.gsm-
GSM;
Cal - , ;
PhoneBook - , ;
SMS - , SMS .
com. Siemens .mp. io .
ConnectionListener - , ;
Connection - SMS IrDA;
File - .
com. Siemens .mp. Icdui ' Image
Java 2 ME.
Image - ,
.
com. s iemens . mp. m5 5 - Siemens m55 .
Ledcontrol ;
com. Siemens .mp.media Mobile Media API.
Control - , ;
,
Controllable - , ;
Player - , -;
PlayerListener - , ;
TimeBase - , .
com..Siemens .mp.media, control. .
ToneControl - ;
VolumeControl .
com. Siemens .mp.ui - Image
com ..Siemens .mp. Icdui.

Sony Ericsson
Q Image - , Image
com. Siemens .mp. Icdui, .

4.3.
Sony Ericsson
Sony Ericsson
Java 2 ME.
Sony Ericsson
. , . \Sony Ericsson :
Q Sony Ericsson J2ME SDK 2.1;
Sony Ericsson SDK 2.1 Patch;
Q Sony Ericsson Communication Suit
Sony Ericsson, ,
Sun Microsystems. Sony Ericsson J2ME
SDK 2.1 J2ME Wireless Toolkit.
J2ME Wireless Toolkit.
J2ME Wireless Toolkit 1
MIDP 1.0, J2ME Wireless Toolkit 2
MIDP 2.0. , Sony Ericsson J2ME SDK 2.1
.
, ' J2ME Wireless Toolkit 2.1 3.
Sony EricssonJ2ME SDK 2.1 :
,
, rie . - . 4.13, Custom Setup.
i J2ME Wireless Toolkit 1 J2ME Wireless
Toolkit 2, MIDP 1.0
MIDP 2.Q .
J2ME Wireless Toolkit 1 MIDP 1.0,
:
Q P800;
4
Q T610;
Q T616;
Q 630;

Z600.


Isr Sony Ericsson J2ME SDK 2.1.0_Beta - InstallShieJd Wizard
Custom Setup
Sebct the program features you want installed.
Click on an icon in the list below to change how a feature is installed.
Feature Description
WTK1 supports P80Q, T628,
T630, Z600, Z608 and T610
! Series (T610, T618 and T616).

Documentation
OnDeviceDebug
PC Emulation
WirelessToolKit.2.0
jgJrJ WTK2 MultiMedia support files

This feature requires 2SMB on


your hard drive.

InstaP to:
C:\SonyEricssonU2ME_SDK\PC_Emulatton\WTKH

Help

| [

Space

<Back

Change..,

l\text>

J[

Cancel

4.13. Custom Setup


,
J2ME Wireless Toolkit:
Q Default Color Phone - ;
Q Default Gray Phone - ;
Q MinimumPhone - .
J2ME Wireless Toolkit 2 - :
Q Z1010;
Z500;

7.

MIDP 2.0,
Sony Ericsson.
SUN ONE
Studio 4 Mobile Edition, Sony Ericsson. SUN ONE Studio 4 Mobile
Edition, Explorer
Device Emulator Registry. , Installed Emulators Add emulators. Select emulator
installation directory, , Sony Ericsson Add.
Sony Ericsson J2ME SDK 2.1,
Select emulator installa-

Motorola
tion directory J2ME Wireless Toolkit 1: C:\SonyEricsson\J2ME_SDK\
PC_Emulation\WTKl. J2ME Wireless Toolkit 2: C:\SonyEricsson\
J2ME_SDK\PC_Emulation\WTK2.
Sony Ericsson.
\Sony Ericsson - Sony Ericsson
Communication Suite Sony Ericsson .

4.4.
Motorola
Motorola \Motorola
- , . Motorola Lanchpad.
Motorola Lanchpad, , . 4.14.
Motorola Launchpad for J2ME
Handset

IV600

Language

(ENGLISH

"Application

Select Handset... [
Advanced,..

::
Explorer...

Class Name
Run From JAD/JAR
Execution Controls

j C:\WTK21\apps\Demo\bin\Demo.jad

Browse.,

* Keep Launchpad open after MIDIet launch'


" Keep command window open after completion
~ Save command fine to batch fie -

Command Line
C:\PROGRA~l\Motorola\SDKV4~l. 1FO\EMULAT~2. l\bin\eroulaYa.exe
"C:\WTK21\apps\Demo\bin\Demo.jad" -deviceRle Resources\V600.props

Launch

Cancel

. ~4,14. Motorola Lanchpad for J2ME

Motorola Lanchpad for J2ME Handset Java 2 ME .


, , Java
, :

388 Simp. Chinese;


388 Trad. Chinese;
6288 Trad. Chinese;
Q 6288 Simp. Chinese;
008 East Europe;
Q A008 North Europe;
Q A008 Simp. Chinese;
Q A008 South Asia;
835;
Q C353t;'
370/450/550;
380;
280;
720;
830;
v60;
v66;
760;
q A630;
650;
398;
725;
V80;

V189;
V220;
V300/V400/V500;

V600.

Handset
Application. , Browse,
JAD JAR , Java.
JAD-. Lanch,
, Motorola Lanchpad for J2ME . Motorola Lanchpad for J2ME
, Keep Launchpad open after MIDlet Launch, Motorola Lanchpad for J2ME.

4.5.
Samsung
\Samsung - JSDKvl_0 - . SamsungJSDK 1.0 ,

Samsung J
. Samsung JSDK 1.0,
. 4.15.

4.15. Samsung JSDK 1.0


Java Samsung JSDK 1.0, File =>
Import MIDlet .
, , . ,
, . , , , Java 2 ME.

.
3 4 , ,


. , ,
Java 2 ME, . , , ,
Java 2 ME.

5.
Java 2 ME
.
Java 2 ME , .
.

.
, , . , . ,
.
.

5.1.
, , . , ,
, - ,

. , , ,
. ,
' Java , . , Java 2 ME. ,
, . , , javax.microedition.midlet.MIDlet.
,
,
, , ,
. Java 2 ME
.
, , main ( ) . , Java 2 SE:
public static void main ( String[] args )

f>


MI Diet, . , . .
JAR- MIDlet suite (
).
2, Sun ONE Studio 4 Mobile Edition
J2ME Wireless Toolkit 2.1, Demo, HelloMIDlet. Sun ONE Studio 4 Mobile Edition,
. 5.1, HelloMIDlet Demo, 2. - \Code\Listing5_l\src.
/**
5.1
HelloMIDlet.Java
*/
//
import javax.microedition.midlet.*;
import javax.microedition.Icdui.*;
,
// HelloMIDlet
public class HelloMIDlet extends MIDlet implements
CommandListener
{
// '
private Command exitCommand;
//
private Display mydisplay;
// HelloMIDlet
public HelloMIDlet()
{
mydisplay = Display.getDisplayfthis);
//
exitCommand = new Command(, Command.SCREEN, 2);
}
//
public void startAppf) /
{
//' TextBox
TextBox t = new TextBox("HelloMIDlet","",256, 0) ;
//
t.addCommand(exitCommand);


//
t.setCommandListener(this) ;
//
mydisplay.setCurrent(t);
//
public void pauseAppO {}
//
public void destroyApp(boolean unconditional) {}
//
public void ommandAct ion (Command , Displaya'ble s)
//
if. ( == exitCommand)
{

// .

destroyApp(false);
notifyDestroyed() ;
t, -

, -
: startApp ( ) - , pauseApp ( ) destroyApp ( ) . , , ,
.
: start ( ) , stop ( ) destroy ( ) . ,
- main ( ) ,
.
,
. . 5.1 .

. 5.1.

Java 2 ME
HelloMIDlet Demo,
Java 2 ME.
5.1 - .
import j a v a x . m i c r o e d i t i o n . m i d l e t . * ;
import javax.microedition.Icdui.*;
Java 2 ME. javax.microedition.midlet.* MIDlet, MIDP.
. ,
.
.
, , ,
. :
public class HelloMIDlet extends MIDlet implements
CommandListener
, MIDlet,
startAppO, pauseAppO destroyApp(). CommandListener,
commandAction ( ) .
Command Display.
private Command exitCommand;
private Display mydisplay;
exitCommand commandAction(). mydisplay
Display, . HelloMIDlet exitCommand mydisplay.
public HelloMIDlet()
{
mydisplay = Display.getDisplay(this);
exitCommand = new Command!"",Command.EXIT, 2 ) ;
}
HelloMIDlet, mydisplay Display getDisplay ( ) .
. , Display ^ new. ,
. Display . Display , , -

. .

, Display. getDisplay ( ) , Display
mydisplay. , , setCurrent (),
:
mydisplay.setCurrent() ;
HelloMIDlet ( } Command
exitCommand. Command ,
.
CommandListener .
. 5.2, ,
.
. , -
. , ,
.
Command
.
, ,
. 5.2.
Command:

public Command( String label, int
commandType, int priority )
Command:
Q label - String,
: . , . - .
, Command ;
O commandType - .

Cl
Q
Q
Q

BACK, CANCEL, EXIT, HELP, ITEM, SCREEN, STOP.


BACK - ;
CANCEL - ;
EXIT - ;
HELP - ;

Java 2 ME
Q ITEM - Choice,
;
Q SCREEN - ;
STOP - .
Q priority - , , . -
, .
HelloMIDlet ( ) startApp ( ) .
public void s t a r t A p p ( )
{
TextBox t = new TextBox{"HelloMIDlet","",256, 0 ) ;
t.addCommand(exitCommand);
t.setCommandListener(this) ;
mydisplay.setCurrent(t);
}
startApp ()
.
TextBox. ,
, TextBox:
public TextBox (String t i t l e ,
String text,
int naxSize,
.int constraints)
TextBox:
Q t i t l e - ,
;
Q text - , . ,
, null;
maxSize
;
Q constraints - , 0.
, TextBox, ,
.
:
t.addCommand(exitCommand);
t.setCommandListener(this);
, TextBox, setCommandListener ()


,
CommandListener . :
mydisplay .setCurrent (t } ;
.
Internet Explorer. setCurrent ( ) , . :
public void p a u s e A p p ( )
, .
destroyApp ( ) , , .
commandAction ( ) CommandListener .
public void commandAction (Command c, Displayable s)
{
if (c == eXitCommand)

destroyApp (false) ;
notifyDestroyed( ) ;

,
. .
destroyApp ( ) notifyDestroyedf ) .
, , .

5.1.1.
HelloMIDlet , HelloMIDlet. , , MIDlet suite ( ),

, . , , ,
. , , . . 5.3 .
, Select (), -

Java 2 ME
. 5.3. 1
Phone

Zoom

. Select,
, s t a r t A p p O , .
startApp ( ) , . , startApp ( ) :
, , , startApp ( ) .

TextBox,
. ,
,
text TextBox.
, . ,
. , . ,
commandAction(),
, exitCommand. - destroyApp ( )
notifyDestroyed(), ,
, ,
,
. . . 5.4
.
- ,
. , , , -, , -, .
, , ,
,

.
,
. 5.4.

Help


Java 2 ME,
. , 7, .

5.2.
5.1, ,
. , . , . Java 2 ME
.
,
. Java 2 ME Java 2 SE.
,
. . ,
, .
, , .
, Display.
Di splay,
getDisplay ( ) . .
Java 2 ME javax.microedition.lcdui, UI (user
interface). , ,
.
Displayable.
Displayable
. . 5.5
javax.microedition.lcdui.
Display
, Displayable . 5.5.

Java 2 ME

. Displayable
. , TextBox, ,
, List - , .
,
. 5.5, : Screen- Canvas. , Screen
Canvas.
, .
, , . , HelloMIDlet Demo TextBox,
.
TextBox - , ,
.
- , , , , ,
.
, . ,
, , , .
, .
. 5.5 javax.microedition.lcdui.*, Canvas GameCanvas
7 8. Alert, TextBox,
Form List :
Q Alert - ;
Q TextBox - ;
Q Form - , Item;
Q List - ,
.

5.3.
,
.
.

.
Java 2 ME. 6
.

/ .
TextBox, Form,
List Alert.
, .
, ,
, , . , , UML,
. . 5.6
.

. 5.6.
.
Form,
. Form, List,
TextBox Alert , . Form, : TextBox.
Form TextBox, :
. List, . Alert,

Java 2 ME
Alert List. Alert , . .
:
import javax.microedition.midlet.*;
import javax.microedition.Icdui.*.
Perexod, MIDlet.
public class Perexod extends MIDlet implements
CbmmandLi s t ener
Command. exitMidlet
. ,
, 5.1.
:
/

private
private
private
private
private

Command exitMidlet;
Command perexodTextBox;
Command perexodList;
Command perexodAlert;
Display mydisplay;

. Perexod.
Display mydisplay:
mydisplay = Display.getDisplay(this);
Command,
, Text Box.
exitMidlet = new Command("", Command.EXIT, 1);
perexodTextBox = new Command("", Command.SCREEN,

2)';

* - .
. Command
MainMidlet,
. start ( ) , Form. addCommand ( ) - - TextBox.
Form setCommandListener ( ) myform Form
setCurrent().


public void s t a r t A p p ( }
{
Form my form = new F o r m ( " F o r m " ) ;
myform.addCommand(exitMidlet);
my form.addCommand't perexodTextBox) ;
myform.setCommandListener(this);
//
mydisplay.setCurrent(myform);
}

, Perexod,
startApp ( ) .
commandAction ( ) CommandListener . , ,
exitMidlet.
if ( == exitMidlet)
-.
destroyApp(false);
notifyDestroyed();
}
. ? Form
perexodTextBox, ' TextBox.
TextBox,
perexodList , List,
. TextBox . , :
if ( == perexodTextBox)
(
TextBox tb = new TextBox("TextBox", "", 256, 0);
perexodList = new Command("", Command.SCREEN, 2);
tb.addCommand(exitMidlet);
tb.addCommand(perexodList) ;
tb. setCommandListener (this)";'
Display.getDisplay(this).setCurrent(tb);

|(

Java 2 ME

i f:
Display.getDisplay(this).setCurrent(tb);
tb Text Box . ,
. ,
Di spl ey, , , , Displayable. Displayable
.
, . ,
, , , . , .
List. , List TextBox.
if ( == perexodList)

'{
List mylist = new L i s t ( " L i s t " , List.IMPLICIT) ,
perexodAlert = new Command("", Command.SCREEN, 2 ) ;
mylist.addCommand(exitMidlet);
mylist.addCommand(perexodAlert);
mylist.setCommandListener(this);
Display.getDisplay(this).setCurrent(mylist);

}
Alert , Alert, . Alert , ,
.
Alert , , . , , 5.2; \Code\Listing5_2\src.

/**
5 . 2

*/
//


import javax.microedition.midlet .*;
import javax.microedition. icdui . *;
// Perexod
public class Perexo<^ extends MIDlet implements
CommandListener
{
//
private Command exitMidlet;
/ /
private Command perexodTextBox;
private Command perexodList ;
private Command perexodAlert;
/ /
private Display mydisplay;
// Perexod
public Perexod ()
i
{
mydisplay = Display. getDisplay (this) ;
//
exitMidlet = new Command (" ", Command. EXIT, 1); t
II TextBox
perexodTextBox = new Command (" ", Command . SCREEN ,
2);
//
public void startAppO
// Form
Form myform = new Form (" Form");
//
my form.addCommandf exitMidlet) ;
// TextBox
form.addCommand (perexodTextBox) ;
//
Form
myform. setCommandListener ( this) ;
/ / .
mydisplay .setCurrent (myform) ;
public void pauseApp ( ) { }
public void destroyApp (boolean unconditional) {}
//
public void commandAct ion (Command c, Displayable d)

Java 2 ME
/ /
if ( == exitMidlet)
{
destroy App( false) ;
notifyDestroyed( ) ;
}
// TextBox
if ( == perexodTextBox)
{
TextBox tb = new TextBox ( "TextBox" , "", 256, 0);.
perexodList = new Command ( "' ", Command. SCREEN, 2) ;
tb . addCommand ( exitMidlet) ;
tb . addCommand ( perexodList) ;
tb.setCommandListener (this) ;
Display .getDisplayf this) .setCurrent (tb) ;
}
// List
if ( == perexodList)
{
List mylist = new ListC'List", List .IMPLICIT) ;
perexodAlert = new Command (" ", Command . SCREEN ,
2);

mylist .addCommand (exitMidlet) ;


mylist .addCommand (perexodAlert) ;
mylist .setCommandListener (this) ;
Display .getDi splay (this) .setCurrent (mylist) ;
}
// Alert
if ( '== perexodAlert)
{
Alert myalert = new Alert ( "Alert" , "" ,null, null) ;,
Display .getDisplay( this) .setCurrent (myalert) ;

,
,
Java 2 ME.

5.4.
5.2 . , - -


addCommand (.), commandAction ( ) , .
, .
. , .
,
. ,
Java 2 ME ,
, , .
, , - .
Display able
, . addCommand ( ) ,
( ), . , , ,
. . 5.7 , J2ME
Wireless Toolkit 2.1.
Displayable,
, . .
Form, List, TextBox Alert , , , , .
.
.
,
, , ,
. . 5.8
.
, .
, Navigator.
public class Navigator extends MIDlet
implements CommandListener
. 5.7.

Java 2 ME

Form

TextBox
List
Alert

TextBox

List
Form
TextBox
Alert

Form
List
Alert

Alert

. 5.8.
Navigator,
, .
private Command exitMidlet = new Command("",
Command.EXIT, 1);

Form, TextBox, List Alert.
, .
private Command
Command.SCREEN,
private Command
Command.SCREEN,
private Command
Command.SCREEN,
private Command
Command.SCREEN,

perexodTextBox = new Command(" TextBox",


2);
perexodList = new Command("B L i s t " ,
2);
perexodAlert = new Command("B Alert",
2) ;
perexodForm = new Command("B Form",
2) ;

, , , .
Command, , Form, TextBox, List Alert.
, , commandAction ( ) if
.

Form, TextBox, List Alert.
private Form myform = new Form(" Form");
private List mylist = new L i s t ( " 3 T O L i s t " ,
List.IMPLICIT);
private TextBox mytextbox = new TextBox(" TextBox",
"", 256, 0 ) ;


private Alert myalert = new A l e r t ( " A l e r t " ,
",null,null);
private Display mydisplay;

"Alert

Navigator
mydisplay.
public Navigator()
{
mydisplay = Display.getDisplay(this);
}
- start ( ) .
, . Form.
, , .
public void startAppO
{
myform.addCommand(exitMidlet);
myform.addCommand(perexodTextBox);
myform.addCommand(perexodList);
myform.addCommand(perexodAlert);
myform.setCommandListener(this);
mydisplay.setCurrent(myform);
}
startApp ( ) myform
. , , , .
, myform, Menu.
Menu,
, Text Box, List
Alert,

commandAction ( ) . ,
, 5.2 .
, TextBox.
if ( == perexodTextBox)
{
mytextbox.addCommand(exitMidlet);

Java 2 ME
mytextbox.addCorranand(perexodForm);
mytextbox.addCommand(perexodList-) ;
mytextbox.addCommand(perexodAlert);
mytextbox.setCommandListener(this);
mydisplay.setCurrent(mytextbox);

}
, , Form, TextBox, perexodTextBox.
mytextbox, , mytextbox.
my form
.
mylist
perexodList mytextbox.
,
mylist. 5.3
, ,
.
/**

5.3

*/
import javax.microedition.midlet.*;
import javax.microedition.Icdui.*;
public class Navigator extends MIDlet implements
CommandListener
{
// .
private Command exitMidlet = new Command("",
Command.EXIT, 1);
// TextBox
.
private Command perexodTextBox" = new Command("B TextBox", Command.SCREEN, 2) ,// List
private Command perexodList = new Command("B List",
Command.SCREEN, 2);
//. Alert
private Command perexodAlert = new Command("B Alert", /
Command.SCREEN, 2) ;
// Form


private Command perexodForm = new Command ("B Form",
Command , SCREEN , 2 ) ,// Form
private Form myform = new (" Form")
// List
private List mylist = new List (" List",
List. IMPLICIT) ;
//^ TextBox
private TextBox mytextbox - new TextBox("3TO TextBox",
"" , 256, 0) ;
// Alert
private Alert myalert = new Alert (" Alert" , "Alert
" , null , null) ;
// mydisplay
private Display mydisplay;
public Navigator ()
{
mydisplay = Display .getDisplay( this) ;

public void startAppO


.{
// Form
myform.addCommand(exitMidlet) ;
myf orm.addCommand(perexodTextBox) ;
myform.addCommand(perexodList) ;
myform.addcommand (perexodAlert) ;
// - Form
myform.setCommandListener (this) ;
//
mydisplay .setCurrent (myform) ;

public void pauseApp ( ) {}


public void destroy App (boolean unconditional) {}
public void commandAct ion (Command c, Displayable d)
{
/ /
if ( == exitMidlet)
{
destroy App (f.alse) ;
notifyDestroyed ( ) ;

Java 2 ME
//. TextBoxif (c ==,perexodTextBox)
mytextbox.addCommand(exitMidlet);
mytextbox.addCommand(perexodForm);
mytextbox.addCommand(perexodList);
mytextbox.addCommand(perexodAlert);
mytextbox.setCommandListener(this);
mydisplay.setCurrent(mytextbox);
// List
if (c == perexodList)
mylist.addCommand(exitMidlet);
mylist.addCommand(perexodForm);
mylist.addCommand(perexodAlert);
mylist.addCommand(perexodTextBox);
mylist. setCommandListener (this) ;
mydisplay.setCurrent(mylist);

; '

// Alert
if (c ==. perexodAlert)
mydisplay.setCurrent(myalert);
// Form
if (c == perexodForm) mydisplay .setCurrent'(my form) ;

}
}
,
, , .

6.

Java 2 ME javax.microedition.lcdui,
. 5, .

.
,
. , , , , , .
,
, ,
, ',
.
. 2,
Java 2 ME.
,
-
MIDP. , MIDP 1.0, , MIDP 2.O. , ChoiceGroup MIDP 1.0 , MIDP 2.0 , ,
. Java 2 ME -
, . , , MIDP 1.0,

MIDP 2.0. MIDP 2.0,
.

6.1. Form
5 , Form. , Form . , Form

I!

Java 2 ME

,
. , ,
. Form .
, , . , ,
, Form
.
Form , . , :
public Form (String title)
Form:
title - .
Form ,
,
public Form (String title, Itein[] items)
Form:
Q t i t l e - ;
Q items - Form.
Form , ,
. Form ,
Item. Item. To ,
Form,
Item. Item
, Form.

6.1.1. Form
Q int append (Image img) - .
Image ,
, ;
Q int append (Item item) -
Item ;
Q int append (String s t r ) - ;
Q void delete (int itemNum) - , itemNum;
Q void deleteAll ( ) - ;
Q Item get (int itemNum) - ;
Q int getHeight ( ) ' -
;

Form
int getwidth ( ) -
. ;
Q void insert (int itemNum, Item item)
;
Q void set (int itemNum, Item item) - ,
itemNum, ;
Q void setltemStateListener (ItemStateListener iListener) nepeMeHHyro.iListener , iListener;
Q int size () - .

, , :
Form my form = new Form ( "" ) ;
myform. append (iteml) ;
myform. append (item2);
.
, , . Form .
. . 6.1 .
, , . Form,

, .
.
, .
, , .
,
, 180, , .
. , , . 6.1.

.
.
.

6.2. Item
Item . ,
, Text Field, ,
. , ,
, Form. 6.2 Item.

. 6.2. Item
G ChoiceGroup - . ;
Customltem - ;
ID DateField - , ;
Gauge - , ;
Q Imageltem - ;
Ul Spacer ;
Q Stringltem-
. , ;
G TextField - .
Item
, Form.
Item ,

Item
. , . Item , , .
,
, Item .

Item
Q void addCommand (Command cmd) - . ;
Q String getLabeK) - Item;
Q int getLayout ()'-
:
Q LAYOUT_LEFT - ;
LAYOUT_RIGHT - ;
Q LAYOUT_CENTER - ;
LAYOUT_TOP - ;
LAYOUT_BOTTOM - ;
Q LAYOUT_VCENTER - . |.
int getMinimumHeight ( j - ;
Q int getMinimumWidth() - ;
Q int getPref erredHeight ( ) -
;
int
getPreferredWidth() -
;
Q void .notifyStateChanged() - , .
ItemStateListener ;
Q void removeCommand(Command cmd) - ;
Q void setDefaultCommand (Command cmd) -
;
Q void setltemCommandListener(ItemCommandListener 1)- ;
Q void setLabel (String label) -
;
Q void setLayout (int layout) - ;
Q void setPreferredSize(int width, int height) -
. .
Item. Item '

, . .

6.2.1. ChoiceGroup
ChoiceGroup
.
: (EXCLUSIVE), (MULTIPLE) (POPUP). 6.3, ,
.
6.3,

POPUP. ,
. .
,
. , . 6.3 MULTIPLE. , ..
.
,
6..
.

EXCLUSIVE,

. ChoiceGroup

ChoiceGroup.
. :
public ChoiceGroup(String label,int choiceType)
ChoiceGroup:
label - ;
Q choiceType - , .
, , : Choice.EXCLUSIVE,
Choice.MULTIPLE Choice.POPUP.
,
:
public ChoiceGroup(String label,
int choiceType,
String[] stringElements,
Image[] imageElements)

Item
ChoiceGroup:
Q String - ;
Q choiceType - , ;
Q str ingElement s - ;
Q imageElements -
.
ChoiceGroup
, ,
:
String[] string = {" 0 " , " 1"," 2 " , " 3 " }
Form
, ChoiceGroup append ( ) Form, :
ChoiceGroup groupMultiple = new ChoiceGroup("
Multiple", ChoiceGroup.MULTIPLE);
ChoiceGroup groupPopup = new ChoiceGroup("
Popup",ChoiceGroup.POPUP);
ChoiceGroup groupExclusive = new 'ChoieGroup("
Exclusive", ChoiceGroup.EXCLUSIVE);
Form myform = new Form(" ChoiceGroup");
myform.append(groupPopup);
myform.append(groupMultiple);
myform.append(groupExclusive);
. ChoiceGroup, , .

ChoiceGroup
, .
int append (String stringPart,Image imagePart) -
;
Q void delete (int elementNum) - ;
Q void deleteAHO - ;
Q Font getFont(int elementNum) -
;
Q Image getlmage(int elementNum) - ;
Q int getSelectedFlags(boolean[]selectedArray_return) - Boolean .
;

Q int getselectedlndex()-
;
U void insert (int e^mentNum, String stringPart,Image imagePart) - ;
U boolean isSelectedt int elementNum) - .
void set(int elementNum, String stringPart, Image imagePart) - , ;
Q void setFont(int elementNum, Font font) -
;
Q void setSelectedlndex(int elementNum, boolean selected)
;
Q int s i z e ( ) - .
, ,

ChoiceGroup. , , Form , Choi ceGroup. , .
, .
. , , - . ,
, . ,
,
. 6.1
, -
\Code\Listing6_l\src.
/**

6.1
ChoiceGroup
*/
import javax.microedition.midlet.*;
import javax.microedition.Icdui.*;
public class MainClassChoiceGroup extends MIDlet
implements CommandListener
{
//

Item
private Command exitMidlet = new Command (" ",
Command . EXIT , 0 ) ;
//
private Command vibor '= new Command (" ", Command . SCREEN , 1) ;
//
private Command vozvrat = new Command ( "" ,
Command . BACK , 0) ;
// ChoiceGroup
private ChoiceGroup groupPopup;
// Form
private Form my form,
// mydisplay -
private Display mydisplay;
public MainClassChoiceGroupf){
mydisplay = Display .getDisplay( this) ;
}
//
private String [] mygroup = {" ", " 1"," 2",
" 3 " } ;
public void startAppO
{
// groupPopup
groupPopup = new ChoiceGroup ( " Popup",
ChoiceGroup . POPUP , mygroup , null ) ;
// Form
myform =. new Form( ChoiceGroup ) ;
//
my form. append (groupPopup) ;
my form.addCommand( exitMidlet) ;
myform. addCommand (vibor) ;
myform. setCommandListener (this) ;
//
mydisplay .setCurrent (myform) ;
public void ,pauseApp( ) {}
public void destroyAppf boo lean unconditional) {}
public void commandAction (Command c, Displayable d)


//
if( == exitMidlet)
{
destroyApp(false);
notifyDestroyed();
}
// myform
if( == vozvrat)
{
mydisplay.setCurrent(myform);
}
//
if( == vibor)

int i = groupPopup.getSelectedlndex();
if(i == 0)
{
Form formPopup = new Form(" formPopup"+
mygroup[0]);
formPopup.append(mygroup[ 0 ] ) ;
formPopup.addCommand(vozyrat);
formPopup.addCommand(exitMidlet);
formPopup.setcommandListener(this);
mydisplay.setCurrent(formPopup);
}
if(i == 1)
{
Form formPopup = new Form(" formPopup"+
mygroup[1]);
formPopup.addCommand(vozvrat);
forraPopup.append(mygroup[1]);
-formPopup.addCommand(exitMidlet);
formPopup.setcommandListener(this);
mydisplay.setCurrent(formPopup);
}
if(i == 2)
{
Form .formPopup = new (", formPopup" +
mygroup[2]);
formPopup.append(mygroup[2]);
formPopup.addCommand(vozvrat);
formPopup.addCommand(exitMidlet);
formPopup.setCommandListener(this.) ;
mydisplay.setCurrent(formPopup);

Item
if(i == 3)
{
Form formPopup = new Form (" formPopup"+
mygroup [ 3 ] ) ;
formPopup. append (mygroup [3 ] ) ;
formPopup. addCommand(vozvrat) ;
formPopup . addCommand (exitMidlet ) ;
formPopup. setCommandListener (this) ;
mydisplay .setCurrent (formPopup) ;

MainClassChoiceGrop.
exitMidlet -
vozvrat vibor. vozvrat , .
vibor, , . ,
POPUP ( ), , Form. 6.1 Form, ChoiceGrop Display.
:
private String[] mygroup = {" 0 " , " 1"," 2 " ,
" 3 " } ;
mygroup
. , mygroup
startApp ( ) . startApp ( )
groupPopup ChoiceGroup. ,
.
. ChoiceGroup, mygroup,
( POPUP ChoiceGroup). , , .
ChoiceGroup
,
, .
( , , ),
null. groupPopup

EEElfliBIHIIIII

Form, , ,
groupPopup ChoiceGroup
Form. :
mydisplay.setCurrent(myform);
.
,
.
Select, ,
,
.
, , , vibor. getSelectedlndexO
ChoiceGroup, i.
,
. ,
, . ,
. , , Form. , .

6.2.2. DateField
, ,
Item. DateField .

. . 6.4
, .
DateField , , . :
public DateField(String label, int mode);
DateField:
Q label - ;
D mode - , ,
DateField .
DATE, ,

Item
6.4.
TIME. DATEJTIME
.

.
public DateField(String label,
int mode,
TimeZone timeZone)
acca Da t e F i e 1 d:
Q label-;
Q mode -
DateField;
Q timeZone- TimeZone,
. :
TimeZone v = TimeZone.getTimeZonet"GMT");
DateField :
,
Q Date getDate ( ) - ;
void setDate(Date date) - ;
Q int get!nputMode() - ' DATE,
TIME DATA_TIME;
Q void setlnputMode (int mode) - DATE,
TIME DATEJTIME.
,
. , -
, DateField. . Java 2 ME,
. 6.2
, - -'
\Code\Listing6_2\src.;

'/**
6 . 2
DateField
*/

- .

import javax.microedition.midlet.*;
import javax.microedition.Icdui.*;


public class MainClassDateField extends MIDlet implements
CommandListener
<
//
private Command exitMidlet = new Command ( ,
Command . EXIT , 0 ) ;
// DateField
private DateField dt;
// Form
private Form my form,
// mydisplay
private Display mydisplay;

public MainClassDateField ()
{
mydisplay = Display .getDisplay( this) ;
public void startAppO
{
// dt
dt = new DateField ( " ", DateField. DATE_TIME )
// Form
myform = new Form ( " DateField");
// dt
my form, append (dt ) ;
my f orm.addCommand ( exitMidlet );
myform. set CommandListener (this) ;
//
mydisplay . setCurrent (myform) ;
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable d)
*
i
//
if( == exitMidlet)
destroyApp(false);
notifyDestroyed();
}
}

Item

MainClassDateField,
. DateField. dt
DateField, . startApp ( ) .
Form dt . , : , . 6.4,
. dt DateField,
, , :
Form f = new Form(new D a t e F i e l d ( " ",
DateField.DATE_TIME);
*\\
,

.
, ,
time date. Select, , ,
, . 6.4.
,
.

6.2.3. TextField
,
.
.
. TextField
, .
public TextField(String label,
String text,
irit maxSize,
int constraints)

TextField:
label - , ;
text - . ;
Q maxSize - ;
Q constraints , , , ,
, :
Q static int ANY - ;
Q static int DECIMAL - ;
Q static int EMAILADDR - ;

'

EE3HHIHHIIII8

static int NUMERIC- ;


Q static int PASSWORD - ;
static int PHONENUMBER - ;
static int URL - .
, ,
Java 2 ME. Java 2 ME , , :
TextField t.f = new T e x t F i e l d ( " " , " " , 2 0 , T e x t F i e l d . U R L ) ;

TextField
TextField ,
.
Q void delete (int o f f s e t , int length) - ;
Q int getCaret Posit ion --
;
int getChars (char [ ] data) -
;
Q int g e t M a x S i z e f ) -
TextField;
String getStringO - ;
, Q void insert(char[] data, int o f f s e t , int length, int
position) - ;
Q void insert (String src, int position) -
;
Q void setChars (char[ ] data, int o f f s e t , int length) - ,
;
int size ()- TextField
.
,
TextField. , . 6.3 .

/**
6.3
TextField
*/
import javax.microedition.midlet.*;
import javax.microedition.Icdui.*;
public class

MainClassTextField extends MIDlet

Item .
implements CommandListener
{
//
private Command exitMidlet = new
Command ( " " , Command . EXIT , 0 } ;
// Form
private Form myform;
// mydisplay '
private Display mydisplay;
'public MainClassTextField( )
{
mydisplay = Display .getDisplay( this) ;
}
public void startAppO
{"
// Form
myform = new Form( " TextField");
//
my form. append (new TextField(
" : " ,." " ,20 .TextField. ANY) ) ;
//
my form. append (new TextField (
" : '* , " " ,20 , TextField. PASSWORD) ) ;
// e-mail
my form. append (new TextField (
" E-mail : " , " " ,20 , TextField. EMAILADDR) ) ;
/ / URL
. my form. append (new TextField (
" URL: " , " " ,20 , TextField. URL) ) ;
//
my form. append (new TextField (
" : " , " " , 20 .TextField. PHONENUMBER) ) ;
my form.addCommand( exitMidlet ) ;
myform.setCommandListerier (this)
;.
mydisplay .setCurrent (myform) ; ,
public void pauseAppO {}
public void destroy App (boolean unconditional)^}
public void commandAction (Command c, Displayabl.e d)


//
if( == exitMidlet)
destroyApp(false);
notifyDestroyedt);
}
}

TextField
- \Code\ Listing6_3\src. 6.3
Form
, , -
. , :
myform.append(new TextField
(" : " , " " , 2 0 , T e x t F i e l d . A N Y ) ) ;

TextField. TextField - ,
TextField, ,
, . , , . 20
. ANY,
.
. 6.3
TextField,
, e-mail, - .
,
. . 6.5 , TextField.

6.2.4. Stringltem
, - . , , -
. 6.5. TextField

Item
, Stringltem . Stringltem, .
public StringItem(String label,String text) :
Stringltem:
Q label - ;
Q text - .
Stringltem
.
public Stringltem(String label,
String text,
int appearanceMode)

Stringltem:
Q label - ;
Q text ;
Q appearanceMode - ,
,., , .
,
javax.microedition.lcdui.Item, .
Q BUTTON - ;
Q HYPERLINK - ;
Q LAYOUT_BOTTOM - ; Q LAYOUT_CENTER - ;
Q LAYOUT_TOP - ;
Q LAYOUT_LEFT - ;
Q LAYOUT_RIGHT - .
Stringltem appearanceMode
Stringltem.
Stringltem
G int get AppearanceMode ( ) - ;
Q Font getFont ( ) - ;
Q String getText ( ) - Stringltem;
void setFont(Font f o n t ) - ;
Q void setPreferredSize(int width, int height) - ;
Q void
setText(String
text) -
Stringltem.


, Stringltem,
Form . , . , .
. 6.4 .
/**

6.4
Stringltem
*/
import javax.microedition.midlet.*;
import javax.microedition.Icdui.*;
public class MainClassStringltem extends MIDlet
implements CommandListener, ItemCommandListener
{
//
private Command exitMidlet = new Command("",
Command.EXIT, 0);
//
private Command perexodButton = new
Command("",Command.ITEM, 1);
//
private Command perexodHyperlink = new Command (" .",
Command.ITEM, 1);
//
private Command vozvrat = new Command("",
Command.BACK, 1);
// Form
private Form myform;
// mydisplay
private Display mydisplay;
\
public void startApp()
{
mydisplay = Display .getDisplayfthis-) ;
myform = new Form(" Stringltem");
Stringltem si = new Stringltem("", "");
myform.append(si);
//
'Stringltem s2 = new Stringltem("",
"www.dmk.ru",Item.HYPERLINK);

Item
s2 . setDefaultCommand (perexodHyperlink) ;
s2 . setltemCommandListener (this) ;
my form. append (s2 j ;
// "
Stringltem s3 = new
Stringltem( "" , "" , Item. BUTTON)-;
s3 . setDef aultCommand (perexodButton) ;
s3 . setltemCommandListener (this) ;
my form. append (s3 ) ;
myf orm. addCommand(exitMidlet ) ;
my form. setCoiranandListener (this) ;
mydisplay . setCurrent (myf orm) ; ,

protected void destroyApp (boolean unconditional) {}


protected void pauseAppO
// ItemCommandListener
public void commandAct ion (Command c, Item i)
{
//
if ( == perexodButton)
{
Form fl = new Form ( "" );
f 1 . append ( " " ) ;
fl.addCommand(exitMidlet-) >
f 1 . addCommand (vozvrat ) ;
f 1 . setCommandListener (this) ;
mydisplay .setCurrent (f 1) ;
}
//
if (c == perexodHyperlink)
{'
Form f2 = new Form ( " " ) ;
f 2 .append( " ");
f 2 . addCommand ( exitMidlet ) ;
f 2 . addCommand (vozvrat );
f 2. setCommandListener (this) ;
mydisplay. setCurrent (f 2 ) ;

public void commandAct ion (Command c, Displayable d)


//
i f ( == exitMidlet)
{
destroyApp ( f a l s e ) ;
notifyDestroyed( ) ;
//
if ( == vozvrat) mydisplay . setCurrent (myf orm) ;

6.4 MainClassStringlt em, ,


ItemCommandListener . startApp ( ) Form Stringltem. :
Stringltem si = new Stringltem ( "" , " " ) ;
. :
Stringltem s2 = new Stringltem ( "" ,
"www.dmk.ru" , Item. HYPERLINK) ;
s2 . setDef aultCommand (perexodHyperlink) ;
s2 . setltemCommandListener ( t h i s ) ;
my form . append ( s2 ) ;
Stringltem s3 = new
Stringltem( "" , "", I tern. BUTTON) ;
s3 . setDef aultCommand (perexodButton) ;
s3 .setltemCommandListener ( t h i s ) ;
myf orm. append ( s3 ) ;
,
setltemCommandListenerQ. . s2 Stringltem . .
. HYPERLINK. s3 .
,
. s3 setltemCommandListener ( ) ,
. .
, CommandListener
ItemCommandListener.
commandAction (Command , Item i ) , ,

Item
. 6.6. gtringitem
.

perexodButton - rexodHyperlink,
. Form, : exitMidlet vozvrat - . commandAct ion (Command , Displayable d) CommandListener. ,
,
ItemCommandListener, commandAction ( } . . 6.6
Stringltem.

6.2.5. Spacer
Spacer ,
.
Spacer. , . Spacer
:
public Spacer (int minWidth, int minHeight) ; ,
Spacer:
G minWidth - ;
minHeight - .
Spacer , , 2 Java 2 ME,
Spacer. Spacer, ,
, , , .
Text Fie Id. 6.5
, -
\Code\Listing6_5\src.
6 . 5
Spacer

imporjt javax .microedition.midlet . * ;


import javax .microedition. Icdui . * ;
public class MainClassSpacer extends MIDlet implements
CommandListener
{
/ /
private Command exitMidlet = new Command ( "" ,
Command. EXIT, 0) ;
// DateField
private Spacer sp,// Form
private Form myform;
// mydisplay
private Display mydisplay;
public MainClassSpacer ( )
{
mydisplay = Display .getDisplay( this) ;

public void startAppO


{
/ / , sp
sp = new Spacer (50 , 0 );
// Form
myform = new Form( " Spacer");
// sp
myf orm. append (sp) ;
myform. append (new
Text.Field(" " , "" ,20 ,TextField.ANY) ) ;
myf orm. addCommand( exitMidlet) ;
myform. setCommandListener (this) ;
//
mydisplay . setCurrent (myform) ;

public void pauseApp ( ) {}


public void. destroyApp (boolean unconditional) {}
public void commandAct ion (Command c, Displayable d)

Item
6.7. Spacer

'

/ / '
if ( == exitMidlet)

destroy App ( f a l s e ) ;
notifyDestroyed( ) ;

6.5 MainClassSpacer Form.


sp Spacer startApp { ) . sp ,
,
TextField. . 6.7 6.5.
Spacer Java 2 ME MIDP 2.0, , , , Spacer .

6.2.6. Im ageItem
Imageltem
Form. PNG (Portable Network Graphics - ),
, , , .
Imageltem. , : .
*
public Imageltem (String label,
Image img ,
int layout ,
String altText)
Imageltem:
Q label - ;
img - Image, ;
Q layout - ,
:
Q public s t a t i c f i n a l int LAYOUT_DEFAULT - ;

Q public s t a t i c f i n a l int LAYOUT_LEFT -


;
Q public static f i n a l int LAYOUT_RIGHT - ;
Q public s t a t i c f i n a l int LAYOUT_CENTER - .
Q altText - ,
. null.
1
Imageltem
:
public .Imageltem(String label,
Image img,
int layout,
String altText
int appearanceMode)
Imageltem:
Q label - ;
Q img Image, ;
Q layout - ;
D altText - , ;
Q appearanceMode - :
BUTTON - ;
Q HYPERLINK - ;
LAYOUT_BOTTOM - ;
Q LAYOUT_CENTER - ;
Q LAYOUT_TOP - ;
G LAYOUT_LEFT - ;
LAYOUT_RIGHT - .
. 4.9
Stringltem ,
.
Imageltem
, . Imageltem Image, Imageltem,
Image.
Image
Imageltem
Form. Imageltem, Image. , :

Item

Image a = Image.'createlmage ( " / r i s . p n g " ) ;


Imageltem b = new Imageltem("", a,
Imageltem.LAYOUT_CENTER,null);
i Image, createlmage ( )
Image. im Imageltem, image.
, ,
. , J2ME Wireless Tollkit 2.1, \res. /ris.png \res. ,
, :
Image ikonl = I m a g e . c r e a t e l m a g e ( " / I k o n / L e v e l 2 / i k o n l . p n g " ) ;
.
,
. 6.6
\Code\Listing6_6\src -.

/**
6.6
Imageltem
*/
import javax.microedition.midlet.*;
import javax.microedition.Icdui.*;
public class MainClassImageltem extends MIDlet implements
CommandListener
{
//
private Command exitMidlet = new Command("",
Command.EXIT, 1);
// Form
private Form myform = new Form("");
// mydisplay
private Display mydisplay;
public MainClassImageltem()
C
mydisplay = Display.getDisplay(this);


public void startApp()
{
//
try{
//
Image image = Image. createlmage (" /gornakov.png" );
// Itemlmage
Imageltem im = new Imageltem( "" ,
image , Imageltem. LAYOUT_CENTER, " " ) ;
//
my form. append (im) ;
} catch (Java . io . lOException ex) { }
// Form
rnyform. addCommand (exitMidlet ) ;
myf orm.. setCommandListener ( this ) ;
/ / ,
mydisplay .setCurrent (myf orm) ,-

public void pauseAppO {}


public void destroy App (boolean unconditional) {}
public void commandAction (Command c, Displayable d)
{
/
if ( == exitMidlet)
* (1}Nokiai100SOK

destroyApp( false) ;
notifyDestroyed( ) ;

:
Forme .
6.6
J2ME Wireless Toolkit 2.1,
', . , ,
, J2ME Wireless
Toolkit 2.1. 6.6 6.8. ,
Imageltem

Item

illil

, 4. 6.8 .

6.2.7. Gauge
Gauge . , , , , ..
, .
, . . , , , .
6.9, .
Gauge ,
. Gauge:
public Gauge(String label,
boolean interactive,
int maxValue,
int initialValue)
Gauge:
Q label - Gauge;
Q interactive - : true
false - ;
Q maxValue - , .
INDEFINITE;
Q static int INDEFINITE - , ,
;
Q initialValue - maxValue.
, .

:
Q static int CONTINUOUS_IDLE - ;
6.9. ,
Gauge


s t a t i c int CONTINUOUS_RUNNING- ;
Q s t a t i c int INCREMENTAL_IDLE- ;
Q static int INCREMENTAL_UPDATING -

.

Gauge
, Gauge, ,
.
void addCommand (Command cmd) - ;
Q int getMaxValue () ;
Q int getValue ( ) - ;
Q void setltemCommandListener(ItemCommandListener 1)- ;
Q void set Label (String label) - ;
void setLayout (int layout) ;
Q void setMaxValue (int maxValue) -
;
void setPreferredSize (int width, int height) - ;
Q void s e t V a l u e f i n t value) .
, . 6.7 Gauge. ,
- \Code\Listing6_7\src.
/ **
6.7
Gauge
*/
import javax.microedition.midlet. *,import javax.microedition.Icdui.*;
public class MainClassGauge extends MIDlet implements
CommandListener

Item

!!

-//
private Command exitMidlet - new Command ( "" ,
Command. EXIT, 1) ;
// Form
private Form myform = new Form( " G a u g e " ) ;
// mydisplay
private Display mydisplay;
public MainClassGauge ( )
{
mydisplay = Display .getDisplay ( t h i s ) ;
}
public void startAppO
{
// Gauge
my form. append (new Gauge ( " : " , true, 10, 5 ) ) ;
// Form
my form.addCommandt exitMidlet) ;
myform.setCommandListener (this) ;
/ /
mydisplay . setCurrent (myform) ;

public void pauseAppO {}


public void destroy App( boolean unconditional)

{}

public void commandAct ion (Command c, Displayable d)


{
//
if ( == exitMidlet)
{
destroy App ( f a l s e ) ;
notifyDestroyedO ;

, , . Gauge , , .
, Gauge
.

6.3. Alert
A l e r t Java 2 ME . A l e r t ,
. , A l e r t . , Alert , , ,
.
String, . 1 t.
public A l e r t ( S t r i n g t i t l e ) ;
public Alert:
Q t i t l e - .
Alert ,
.
public A l e r t ( S t r i n g t i t l e ,
String alertText,
image alertlmage,
AlertType alertType)
public Alert:
Q title- ;
Q alertText - ;
Q alertlmage - ;
Q alertType - , AlertType.
:
Q static AlertType ALARM - ;
s t a t i c AlertType CONFIRMATION -
, ;
Q s t a t i c AlertType ERROR - ;
Q s t a t i c AlertType INFO - ;
Q s t a t i c AlertType WARNING - .
Alert, , , , .

6.3.1. Alert
Alert,
.
Alert.

Alert
Q void addCommand (Command cmd) - ;
Q int getDef aultTimeout ( ) - . FOREVER Alert;
Q Image get Image () - Alert;
Q Gauge getlndicator ( ) - Gauge;
Q String getStringO - ;
Q int getTimeout ( ) - ;
Q AlertType getType ( ) - ;
Q void removeCommand (Command cmd) - ;
Q void setCommandListener (CommandListener 1) -
;
void setlmage (Image img) ;
void setlndicator (Gauge indicator)
Gauge;
G void setString (String str) - ;
Q void setTimeout (int time) - ;
Q void setType(AlertType type) -
.
Alert .
. 6.8 ,
Alert .
\Code\Listing6_8\src.

/.**
6.8
Alert
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class MainClassAlert extends MIDlet implements
CommandListener
{
//
private Command exitMidlet = new Command("",
Command.EXIT, 1);
// Alert

'


Alert al;
// mydisplay
private Display mydisplay;
/
public MainClassAlert ( )
{
mydisplay = Display .getDisplay (this) ;
}, .
public void startAppO
{
//
try{
//
Image image = Image. createlmage (" /error .png" );
// Alert
al = new Alert ( " Alert", null, image,
AlertType . ERROR) ;
} catch ( Java. io.IQException ex) { }
al .addCommand(exitMidlet) ;
al .setCommandListener (this) ;
mydisplay .setCurrent (al) ;
public void pauseAppO {}
public void destroyApp (boolean unconditional)

{}

public void commandAction (Command c, DisplayaMe d)


{
//
if ( == exitMidlet)
{
destroyApp ( false) ;
notifyDestroyed( ) ;

6.8 MainClassAlert,
. al Alert. startApp ( )
Image, .
\Code\Listing6_8\res -.
. 6.10 Alert.

List

llllll

6.10. ,
Alert

try{} c a t c h ( ) { } . , , -
.

6.4. List
List Item. List
,
. List
Screen Choice.
.
, Choice:
Q EXCLUSIVE - ;
Q MULTIPLE - ;
Q IMPLICIT - , .
EXCLUSIVE MULTIPLE ChoiceGroup,
IMPLICIT List. List . .
public List(String title, int listType);
List:
title - ;
Q listType - , : IMPLICIT, EXCLUSIVE MULTIPLE.

listType. List . .
public List(String title,
int listType,
String[] stringElements,
Image[] imageElements)

List:
Q t i t l e - ;
Q listType - IMPLICIT, EXCLUSIVE
MULTIPLE ;
Q stringElements - ;
Q imageElements -
, , 10 10 .

6.4.1. List
List , , .
List.
int append(String stringPart, Image imagePart)-
;
void delete (int elementNum) -
;
"
Q void deleteAHO - ;
Font getFont(int element-Mum)
;
Q Image getlmagetint elementNum) - ;
int getSelectedFlags(boolean[] selectedArray_return)
;
Q int getSelectedlndex ( )
;
Q String getString (int elementNum) -
;
void insert(int elementNum, String stringPart, Image
imagePart) -
;
Q boolean isSelected(int elementNum) - ;
Q void removeCommand (Command cmd) - ;
Q void s e t ( i n t
elementNum,
String stringPart,
Image
imagePart) - ;
Q void setFont(int elementNum, Font font) -
;
Q void setSelectCommand(Command command) IMPLICIT. , ,

List

UIHMEQ

. ,
. : List.SELECT_COMMAND.
;
Q void setSelectedFlags(boolean[] selectedArray)- ;
Q void setSelected!ndex(int .elementNum, boolean selected) ;
Q void setTitle (String s) - ;
Q int size ( ) - .
,
List. List : Exclusive,
Multiple Implicit. , . List
:
Multiple Implicit, Exclusive.
. ,
. Multiple Implicit
. Multiple Implicit,
.
Mu11 ipIe Imp licit. , . 6.9 , - \Code\Listing6_9\src..

/**
. 9
List
*/
import javax.microedition.midlet.*;
import javax.microedition.Icdui.*;
public class MainClassList extends MIDlet implements
CommandListener
{
//
private Command exitMidlet = new - Command("",
Command.EXIT, 0);
//
private Command vibor = new Command("",


Command. SCREEN, I);
//
private Command vozvrat = new Command ( "" ,
Command . BACK , 1 ) ;
// Implicit Multiple
private Command OK = new Command( "OK" , Command. OK, 1);
// EXCLUSIVE
Image [] iconEx = null;
// Multiple
Image [] iconMu - null;
// Implicit
Image [] iconlm = null;
// List EXCLUSIVE
private List mylistEx;
// List Multiple
private List mylistMu;
// List Implicit
private List mylistlm;
// mydisplay
private Display mydisplay;
public MainClassList ( )
{
mydisplay = Display. getDisplay (this) ;

public void startAppO


{
//
try{
//
Image imagel = Image. createlmage ( "/iconMu. png" );
Image image2 = Image. createlmage {" /iconlm. png" );
//, iconEx
iconEx = new Image []
{
imagel , image2
};
//
Image images = Image. createlmage (" /Multiple. png" );
// iconMu
iconMu = new Image [] (image3 , image3 , image3 , imageS } ;
//
Image image4 = Image. createlmage (" /Implicit .png" ),-

List
// iconlirt
iconlm = new Image [] (image4, image4 , image4};
} catch (Java . io . lOException ex) { }
//
String [] st = (" Multiple" , " Implicit"};'
// mylistEx
mylistEx = new List (" EXCLUSIVE",
.Choice. EXCLUSIVE, st , iconEx) ;
//
mylistEx . addCommand (exitMidlet ) ;
my 1'istEx, addCommand (vibor) ;
mylistEx.setCommandListener (this) ;
//
mydisplay .setCurrent (mylistEx) ;

public void pauseAppO {}


public void .destroy App (boolean unconditional) {}
public void commandAct ion (Command c, Displayable d)
{
/ /
if ( == exitMidlet)
{
destroy App ( false) ;.
,
notifyDestroyed ( ) ;
}
//
if ( == vozvrat)
. Display .getDisplay( this) .setCurrent (mylistEx) ;
// OK
if ( == OK)
{
Alert al = new Alert (null , " ",
null , null) ;
mydisplay .setCurrent .(al) ;
}
// vibor
'
if ( == vibor)
{
//
int i = mylistEx. getSelectedlndex ();
// Multiple
if(i == 0)


//
String [] string = { "" , "" , "" , "" };
// mylistMu
mylistMu = ' n e w List (" MULTIPLE", Choice. MULTIPLE,
string, iconMu);
//
mylistMu. addCommand(vozvrat) ;
/ / OK
mylistMu.addCommand (OK) ;
mylistMu. setCommandListener (this) ;
/ /
mydisplay . setCurrent (mylistMu) ;
}
// Implicit
if(i == 1)
{
//
String[] string = { "'" , "" , "" };
// mylistlm
mylistlm = new ListC'Tnn IMPLICIT", Choice. IMPLICIT,
string, iconlm) ;
//
mylistlm. addCommand (vozvrat) ;
// OK
mylistlm. addCommand (OK) ;
mylistlm. setCommandListener (this) ;
//
mydisplay. setCurrent (mylistlm) ;

6.9 MainClassList, .
- exitMidlet, vibor, - vozvrat ,
. : iconEx, iconMu iconlm.

Exclusive, Multiple Implicit List. :
private List mylistEx;
private List mylistMu;

List
private List mylistlm,private Display mydisplay;
List,
mydisplay Display. startAppO
. \Code\Listing6_9\res
createlmage Image. ^!, image2, image3 image4. t r y { } catch ( ) {} . iconEx, iconMu
iconlm .
mylistEx = new List

' EXCLUSIVE",

Choice.EXCLUSIVE,
iconEx)

st,

mylistEx. . List
.
Choice ^EXCLUSIVE.
Exclusive,
. List
st. ,
. .
commandAction ( )
. exitMidlet . vozvrat . ,
Alert. vibor Multiple Implicit List. getSelectedIndex()
if /else . Multiple Implicit Exclusive. . 6.11
,
Li st.
,
List .
. 6.11. List

6.5. Ticker
Ticker
, . ,
Ticker, .
,
. . 6.12
.
Ticker ,
, :
public Ticker (String str)';
Ticker:
Q str - .
Ticker ,
str .

6.5.1. Ticker
Ticker .
String getstring ( ) - ,
Ticker;
void setStr ing ('String str) - Ticker, .

Displayable.
Ticker,
Ticker , Form. :
Q void setTicker (Ticker ticker) -
, ;
Q Ticker getTicker ( ) - .

Ticker. 6.10
Ticker, - \Code\Listing6_10\src.
. 6.12. Ticker

List

/**
6.10
Ticker
*/
import javax.microedition.midlet . * ;
import javax.microedition. Icdui . * ;
public class MainClassTicker extends MIDlet
implements CommandListener
{
/ /
private Command exitMidlet = new Command! "" ,
Command. EXIT, 0) ;
// Form
. .' private Form my form;
// mydisplay
private Display mydisplay;
public MainClassTicker ()
{
mydisplay = Display .getDisplayt this) ;
}
public void startApp ( )
{
// Form
myform = new Form( " Ticker");
// Ticker
Ticker myticker = new Ticker ( " ");
//
myform. setTicker (my ticker) ;
//
my form.addCommand( exitMidlet ) ;
myform. setCommandListener (this) ;
mydisplay .setCurrent (myform) ;

public void pauseAppO {}


public void destroy App (boolean unconditional) {}
public void commandAct ion (Command c, Displayable d)
{
/ /


if ( == exitMidlet)
{
destroy App ( f a l s e ) ;
notifyDestroyed ( ) ;

' 6.10 Form


Ticker . setTicker ( ) ,
Ticker , .

6.6. Image
Image It em
Image, .
Image. .
Image PNG.
.
, . JAR-, , , JAR-.
Alert, Choice, ChoiceGroup,
Form, Imageltem Graphics.
.
,
, .

6.6.1. Image
Image , , , . Image.
G static Image createlmage (byte ['] imageD.ata, int imageOffset, int imageLength) -
- ;
Q static Image createlmage (Image source) - ;
static Image createlmage(Image image, int x, int y, int
width, int height, int transform) -
, , . transform
Sprite :

Image
Q Sprite, TRANS_NONE - ;
Q Sprite.TRANS_ROT90 -
90;
Q Sprite.TRANS_ROTl80-
180;
Q Sprite.TRANS_ROT270 -
270;
Q static Image createlmage (Inputstream stream) -
;
^
Q static Image createlmage{int width, int height) -
;
Q static Image createlmage (String name) -
;
Q static Image createRGBImage(int[]. rgb, int width, int
height, boolean processAlpha) - , ARGB;
Q Graphics getGraphics() ;
int getHeight ( ) - ;
Q int getwidth() - ,
6.11 , Image It em, 6.6 6.8. 6.6 Image, Image
. -
\Code\Listing6_l l\src.

/**
'

6.11
Image
*/

' \- .

import javax.microedition.midlet.*;
import javax.microedition.Icdui.*;
public class MainClassImage extends MIDlet implements
CommandListener
{
//
private Command exitMidlet = new Command("",
Command.EXIT, 1);
// Form
private Form myform = new Form(" Image");
// mydisplay


private Display mydisplay;
public MainClassIrnagef )
{
mydisplay = Display .getDisplay (this) ;
}
public void startAppO
{
//
try{
/ / .
Image im = Image. createlmage ( " /gornakov.png" ) ;
//
my form. append (im) ;
} catch( Java. io. lOException ex) { }
/ Form
myform.addCommand(exitMidlet) ;
myf orm.setCommandListener ( t h i s ) ;
' / /
mydisplay. setCurrent (my form) ;
public void pauseAppO {}
public void destroy App (boolean unconditional) {}
public void commandAction (Command c, Displayable d)
{
//' .
if ( == exitMidlet)
{
destroy App (false) ;
notifyDestroyed ( ) ;

. 6.13 , , , .

6.7. Font

, , , -

Font

6.13. image
, Font,
. ,
, , , .
:
, int SIZE_LARGE - ;
static int SIZE_MEDIUM - ;
Q static int SI ZE_SMALL - .
:
Q static int STYLE_BOLD - ;
Q static int STYLE_ITALIC - ;
,Q s t a t i c int STYLE_PLAIN - ;
Q static int STYLE_UNDERLINED - .
:
Q static int FACE_MONOSPACE - ;
Q static int FACE_PROPORTIONAL - ;
Q static int FACE_SYSTEM - .
MIDP 1.0 Graphics
setFont ( ) . MIDP 2.0,
Graphics,
.
. , -


, ,
get Font ( ) Font :
Font myFont = Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,
Font.SIZE_LARGE);
myFont , . MIDP 2.0 setFont ( ) . MIDP 1.0 , Graphics, 6
.
List, . ,
. 6.12
. - \Code\Listing6_12\src.
/**

6.12
Font
*/
import javax.microedition.midlet.*;
import javax.microedition.Icdui.*;
public class MainClassFont extends MIDlet implements
CommandListener
//
private Command exitMidlet = new Command("",
Command.EXIT, 0);
//
Image[] icon = null;
// List .
private List mylist;
// mydisplay
private Display mydisplay;
public MainClassFont()
mydisplay = Display.getDisplay(this);

public void startAppO


{
/7

try{

Font

lilllBMK

//
Image imaged = Image. createlmage (" /iconO .png" );
Image imagel = Image. createlmage (" /iconl .png" );
Image image2 = Image. createlmage (" /icon2 .png" );
Image image3 = Image. createlmage ( "/icon3 .png" );
// icon
icon = new Image []{ imaged, imagel, image2 , image3 } ;
} catch (Java . io . lOException ex) { }
//
String[] stroka = { "" , "" , "" ,
"" } ;
//
Font fO = Font. getFont (Font . FACE_PROPORTIONAL ,
Font . STYLE_PLAIN , Font . SIZE_SMALL) ;
//
Font fl = Font .getFont (Font . FACE_SYSTEM , .
Font . STYLE_BOLD , Font . SIZE_MEDIUM) ;
//
Font f2 = Font. getFont. ( Font. F AC E_MONO SPACE,
Font . STYLE_ITALIC , Font . SIZE_LARGE) ;
//
Font f3 = Font. getFont (Font. FACE_SYSTEM,
Font . STYLE_UNDERLINED , Font . SIZE_LARGE) ;
// mylist
mylist = new List (" List"', Choice. EXCLUSIVE,
stroka, icon) ;
//
. mylist . setFont ( 0 , f 0 ) ;
//
mylist .setFont (I , fl) ;
//
mylist. setFont (2 , f2) ;
//
mylist . setFont (3 , f 3 ) ;
//
mylist. addCommand ( exitMidlet ),mylist . setCommandListener (this) ;
//
mydisplay. setCurrent (mylist ) ;

public void pauseApp ( ) { }


public void destroy App (boolean unconditional) {}
public void commandAct ion (Command c, Displayable d)


/ /
if ( == exitMidlet)
{
destroy ( f a l s e ) ;
notifyDestroyed ( ) ;

6.13,
, MainClassFont.
List . :
Image [] icon = null
.
,
. mylist List. startApp ( ) ,
.
:
Image
Image
Image
Image

imaged
imagel
image2
image3

=
=
=
=

Image. createlmage ( "/iconO .png" ) ;


Image. createlmage ( " / i c o n l . png" ) ;
Image. createlmage ( "/icon2 .png" ) ;
Image. createlmage ( " /iconS .png" ) ;

, ,
, . :
icon = new Image [] { imageO, imagel, image2 , image3};
:
String [ ] stroka = { "" , "" , "" , "" } .
:
Font f O = Font. getFont ( Font. FACE_PROPORTIONAL ,
Font . STYLE_PLAIN, Font . SIZE_SMALL) ;
Font f l = Font .getFont (Font .FACE_SYSTEM, Font . STYLE_BOLD,.
Font . SIZE_MEDIUM) ;
Font f 2 = Font .getFont (Font . F AC E_MONO SPACE,
Font .STYLE_ITALIC, Font .SIZE_LARGE) ; .
Font f3 = Font .getFont (Font . FACE_SYSTEM ,
Font . STYLE_UNDERLINED , Font . SIZE_LARGE) ;

f 0 ... f 3 ,
, .

Font
6.14. ,


.
my list Exclusive ( ). List
setFont ( ) MIDP 2.0,
.
List,
:
mylist.setFont(0 , f0) ;
mylist.setFont(1,f1);
mylist.setFont(2,f2);
mylist.setFont(3,f3);
setFont ( ) , f O...f 3.
0 3 stroka [ ].


. . 6.14 6.13.
,
, .

. Java 2 ME, .

7.
, 6,
. , , , , ,
, . -
,
Java 2 ME. , , ,
. . Java 2 ME -
Canvas GameCanvas ( GameCanvas ), Graphics, .
Canvas Graphics,
, , .

7.1. Canvas
Canvas - , Canvas. Canvas
, Graphics. ,
Canvas
. , 5
, , Canvas .
,
.
ITU-T
:
s t a t i c int DOWN - ;
Q static int FIRE -
;
Q static int GAME_A - ;
static int GAME_B - ;
Q static int GAME_C - ;
Q s t a t i c ' i n t GAME_D - D;

Canvas
Q static int KEY_NUMO - 0;
Q static int KEY_NUM1 - 1;
Q static int KEY_NUM2 - 2;
Q static int KEY_NUM3 - 3;
Q static int KEY_NUM4 - 4;
Q static int KEY_NUM5 - 5;
Q s t a t i c int KEY_NUM6 - 6;
Q static int KEY_NUM7 - 7;
Q static int KEY_NUM8 - 8;
Q static int KEY_NUM9 - 9;
Q static int KEY_POUND - #;
Q static int KEY_STAR - *;
Q static int LEFT - ;
Q static int RIGHT - ;
Q static int UP .
GAME_A, GAME_B, GAME_C, GAME_D FIRE 2,4,8,6 5, .

7.1.1. Canvas
Canvas -.
. void paint (Graphics g) ,
. Graphics , . Canvas:
Q int getGameAction(int keyCode)
;
Q int getKeyCode(int gameAct ion)
;
Q String getKeyName (int keyCode) - ;
Q boolean hasPointerMotionEvents ( ) - ;
Q protected void keyPressed(int keyCode) - ;
Q protected void keyReleased(int keyCode) - ;
Q protected void keyRepeated(int keyCode) -
;
Q protected abstract void paint (Graphics g) - ;
Q protected void pointerDragged(int x, int ) -
;

protected void pointerPressed(int x, int ) -


, ;
protected void pointerReleased(int x, int ) -
;
void repaint ( ) - ;
void repaint(int x, int , int width, int height) - .

7.2. Graphics
Graphics . Graphics Java 2 SE,
Java 2 ME , . ,
, . .
,
Java 2 ME, X
0.0
. ,
. X

, Y -
, . 7.1.

. DirectX OpenGL
. 7.1.

,
Java 2 ME
.

7.2.1. Graphics
Graphics
. , (clipping). Graphics:
Q void copyArea(int x_src, int y_src, int width, int
height, int x_dest, int y_dest, int anchor) (x_src ,
y_src, width, height), (x_dest, y_dest);

Graphics
void drawArc(int x , int y , int w i d t h , int height, int
startAngle, int arcAngle) - ;
void drawChar(char character, int x, int y , int anchor) -_
;
Q void drawChars(char[] data, int o f f s e t , int length, int
x, int y , int anchor) - :
Q void drawlmage (Image img, int x, int y, int anchor) ;
Q void drawLine.fint x l , int y l , int x2 , int y2 ) -
xl yl, 2 2;
Q void drawRegion(Image src, int x_src, int y_src, int
width, int height, int transform, int x_dest, int y_dest,
int anchor) - ;
Q void drawRoundRect(int x, int , int width, int height,
int arcWidth, int arcHeight) - ,
;
Q void f i l l A r c ( i n t x, int y, int width, int height, int
startAngle, int arcAngle) - ;
Q void f i l l R e c t { i n t x, int y , int width, int height)-
;
Q void fillRoundRect.tint x, int y, int width, int height,
int arcWidth, int arcHeight) - , ;
Q void f i l l T r i a n g l e ( i n t x l , int y l , int x 2 , int y 2 , int x3 ,
int ) - ;
Q int getBlueComponent() ;
Q int getClipHeight - ;
Q int getClipWidth() - ;
Q int getColor ( ) - ;
Q Font get Font ( ) - ;
Q int getGreenComponent ( ) - ;
Q inf getRedComponent ( ) - ;
Q void setClip(int x, int , int width, int height)- ;
Q'void setColor(int RGB) -
RGB;
Q void setColor(int red, int green, int blue) -
red, green blue;
Q void setFont(Font f o n t ) - ;
Q void setStrokeStyle (int s t y l e ) - , SOLID DOTTED;
Q void translate (int x, int ) -
.


,
int anchor. . . 7.2, .
RIGHT

LEFT

TOP

BASELINE

BOTTOM

HCENTER
. 7.2.

Graphics ,
:
static int BASELINE - ;
Q static int BOTTOM - ;
static int HCENTER - ;
static int LEFT - ;
Q static int RIGHT - ;
Q static int TOP - ;
Q static int VCENTER - , .
. ,
, Graphics . LEFT
I Graphics .TOP.

Java 2 ME, , , . - .
; , 128x128 , 101x80, . ,
Canvas; g e t W i d t h O getHeight ( ) ,



, . ,
, ,
:
int w = getWidthO;
drawLine(20, 2 0 , w-20, w - 2 0 ) ;
, . .
DefaultColorPhone
J2ME Wireless Toolkit 2.1,
, , , .

7.3.
drawLine ( ) .Graphics. :
public void drawLine(int
int
int
int
/ -

xl,
yl,
x2,
y2)

'

' ,

drawLine ( ) :
Q xl - X;
Q yl - Y;
Q 2 - X;
2 - Y. .
drawLine ( ) .
setColorO setStrokeStyle ( ) .
7.1,
Java 2 ME. 7.1 - \Code\Listing7_l\src.
/**'"
7.1
Main Line
* / ' , ' '
import javax.microedition.Icdui.*;
import javax.microedition.midlet.*;


public class Main extends MIDlet implements
CommandListener
{
//
private Command exitMidlet = new Command ( "" ,
Command. EXIT, 0); .
public void startAppO
{
// Line
Line myline = new Line ( ) ;
//
myline. addCommandf exitMidlet) ;
myline. setCommandListener (this) ;
Display .getDisplay (this) .setCurrent (myline) ;

public void pauseApp ( ) {}


public void destroy App( boolean unconditional) {}
public void ommandAct ion (Command c, Displayable d)
{
if (c == exitMidlet)
{
destroy App ( false) ;
notifyDestroyed ( ) ;

/**

Line Line. Java


*/
import javax.microedition. Icdui . *;
public class Line extends Canvas
{
/ /
public Line(){ super (); }
public void paint (Graphics g)


//
g.setColor ( O x O O O O f f ) ;
//
g.drawLine(20, 2 0 , 9 0 , 2 0 )
g.drawLine(20, 20, 20, 90)
g.drawLine(90, 2 0 , 80, 10)
g.drawLineOO, 2 0 , 80, 3 0 )
g. drawLi.net 2 0 , 90, 10, 80)
g.drawLine(20, 90, 30, 80)
//
g.setColor(OxffffOOOO) ;
//
g.drawLine(30, 30, 70, 30);
g.drawLine(30, 31, 70, 31);
g.drawLine(30, 32, 70, 32);
//
g . setStrokeStyle (Graphics . DOTTED) ,// (
g.drawLine(30, 50, 70, 50);
g.drawLine(30, 51, 70, 51);

7.1 : Main, , Line, . , Main.java Line.java,


-
. Main .
Line,
. Line, Line.java 7.1,
. Line
Canvas. Run nable run( ) .
, .
Line super () . Canvas. paint ( ) Canvas.
:
g.setColor ( O x O O O O f f )
. setColorO
setColor ( ) ,


. setColor (RGB),
.
7.4
setColor () , .

g.drawLine(20,
g.drawLine(20,
g.drawLine.(90,
g.drawLineOO,
g.drawLine(20,
g.drawLine(20,

20,
20,
20,
20,
90,
90,

90,
20,
80,
80,
10,
30,

20)
90)
10)
30)
80)
80)

, . - .
, .
g . d r a w b i n e ( 3 0 , 30, 7 0 , 3 0 ) ;
g.drawLine(30, 31, 7 0 , 31);
g.drawLineOO, 32, 70, 3 2 ) ;
.
paint ( )
. setStrokeStyle () DOTTER. . 7.3
7.1.
& (1) Nokia 51QQ SDK
Re tods Help

7.4.

Graphics- drawRectO
f illRect ( ) . drawRect ( )
, f illRect ( ) - , ( ).
,
, drawRect ( ) .
public void drawRect(int
int
int
int

x,
y,
width,
height)

. 7..


drawRect ( ) :
Q - X ;
- Y ;
width - ;
G height - .
Graphics , - drawRoundRect ( ) .
,
drawRect ( ) f illRect ( ) , . 7.2 , : , .
setColor (int red, int
green, int blue) . 0 255 , ,
.
,
Display:
isColorO - ,
true;
Q numColor ( ) - .
- 7.2 \Code\Listing7_2\src.

/**
7 . 2
Main Rectangles
*/
import javax.microedition.Icdui.*;
import javax.microedition.midlet,*;
public class Main extends MIDlet implements
CommandListener .,,
{
//
private Command exitMidlet = new Command("",
Command.EXIT, 0);
public void startAppO
{
// Rectangles
Rectangles myrec = new Rectangles();
//
myrec.addCommand(exitMidlet);
myrec.setCommandListener(this);


Display .getDisplay (this). .setCurrent (myrec) ;

public- void pauseAppO {}


public void destroyApp (boolean unconditional) {}
public void commandAct ion (Command c, Displayable d)
{
if (c == exitMidlet)
{
destroyApp ( false) ;
notifyDestroyedf ) ;

/**

*/

Rectangles Rectangles .Java

import j avax. microedit ion. Icdui . * ;


public class Rectangles extends Canvas
{
//
public Rectangles () { super () ; },- .
public void paint (Graphics g)
{
//
g.setColor (255, 0, 0 ) ;
/ /
g.fillRect (/**/ 15, /**/ 3 0 , / ** / 15, /**/ 20);
//
g.setColor(0, 255, 0) ;
/ /
g.fillRect (30, 30, 15, 45);
//
g.setColor(0, 0, 255);
//
g.fillRect(45, 30, 15, 60);
//
g.setColor (255, , );
.//


g.drawRoundRect(70, 3 0 , 4 0 , 4 0 , 10, 10}

- Main,
Rectangles, . Main.java Rectangles.] ava.
Main Rectangles, . Rectangles
Canvas. paint ( )
Graphics.
g.setColor(255, , ) ;
15 20 , f illRect ( ) .
g . f i l l . R e c t ( / * x * / 1 5 , / * * / 30 ,/**/ 15 , /**/ 2 0 ) ;
. .

15x45 15x60 .
Rectangles
. . 7.4
.

. 7.4,

Illi
7.5.

arc ,
nojava2 ME. drawArc ( ) f i l l A r c ( ) , . ,
. drawArc ( ) f illArc ( ) . - f illArc ( ) .
public void f i l l A r c ( i n t
int
int
int
int
int

x,
y,
width,
height',
startAngle,
arcAngle)

f illArc ( ) :
Q x - , X ;
D - , Y ;
Q wight - ( );
Q height - ( );
Q startAngle ;
Q arcAngle - ( 360 ).
, 7.5 .

height

. 7.5.


7.3
, , .
/**

7 . 3

Main Arc
- */
import javax.microedition.Icdui.*;
import javax.microedition.midlet.*;
public class Main extends MIDlet implements
CommandListener
{
//
private Command exitMidlet = new Command("",
Command.EXIT, 0);
public void startAppO.
{
// Arc
Arc myarc = new Arc();
//
myarc.addCommand(exitMidlet);
myarc.setCommandListener(this);
Display.getDisplay(this).setCurrent(myarc);
public void pauseAppO {}
public void destroyApp(boolean unconditional){}
public void commandAction (Comma'nd c, Displayable d)
if (c == exitMidlet)
,

'' i>

destroyApp(false);
notifyDestroyed (.);
}
}
}
/**
Arc Arc.Java

*/


import javax_.microedition . Icdui . * ;
public class Arc. extends Canvas
{
/ /
public Arc ( ) { super (); }
public void paint (Graphics g)
//
g . s e t C o l o r ( 2 5 5 , 0, 0) ;
//
g . f i l l A r c ( 1 5 , 15, 6 0 , 6 0 , 45, 3 6 0 ) ;
//
g.setColor(0, 255, 0);
//
g.fillArc(15, 15, 60, 60, 45, 180);
//
g'. setColor(0, 0, 255) ;
//
g-. fillArc(15, 15, 60, 60, 45, 90);
//
g.setColor(0, 0, 255);
//
g.drawArc(5, 5, 80, 80, 30, 180);

7.3 , 7.2 7.1 - : Main Arc,


Main.java Arc.java. -
\Code\Listing7_3\src.
paint ( ) .
g.setColor (25.5 , , ) ;
g . f i l l A r c ( 1 5 , 15, 6 0 , 6 0 , 45, 3 6 0 ) ;
. f i l l A r c ( ) - 15
15 , . 60 60
. 45 (
360 ). , .

1I1IIHM

7.6.

drawstring ( ) drawChar ( ) , - . , , 6. drawstring ( ) :
public void drawstring

(String str,
int x,
int y,
int anchor)

drawstring ( ) :
Q str - ;
Q x ,
;
anchor - . Graphics,
7.2.
7.4 . , .
- \Code\Listing7_4\src.
/**

7 . 4
Main Text
*/
import javax.microedition.Icdui.*;
import javax.microedition.midlet.*;
public class Main extends MIDlet implements
CommandListener
{
//
private Command exitMidlet = new Command(,
Command.EXIT, 0);
public void startAppO
{
// Text
Text mytext = new Text();
// -
mytext.addCommand(exitMidlet);
mytext.setCommandListener(this);

*.

Display .getDisplay (this) . setCurrent (mytext ) ;

public void pauseApp ( ) {}


public void destroyApp (boolean unconditional) {}
public void commandAetiont Command c, Displayable d)
{
if (c == -exitMidlet)
{
destroyApp ( f a l s e ) ;
notifyDestroyed( ) ;

/**
Text Text. Java

*/

import javax.microedition. Icdui . * ;


public class Text extends Canvas
{
/ /
public Text () {super ();}
public void paint (Graphics g)
{
//
g.setColor (10, 80, 200);
//
g. drawstring (Java 2 Micro Edition,
80, 40, Graphics. TOP I Gra^phi s.HCENTER) ;

7.7.
Canvas Runnable
run ( ) , . DemoGraphics .


public class DemoGraphics extends Canvas implements
Runnable
{.
public void run ( )
{
while (true)
{
//
repaint ( ) ;
// 20

Thread. sleep (20) ;
}
}
public void paint ( Graphics g )
{
// ,
}
public void key-Pressed ( int~ keyCode )
{
//

DemoGraphics ,
, .
: run ( ) , paint ()
key Pressed ( ) .
paint ( )
, run ( ) , , , ,
. , , key.Pressed ( ) , .
.
run ( ) while ( true) . , , .. repaint ( ) . sleep ( )
Thread ,
, ,

. MIDP 1.0
,
.


, , ,
, , .

7.8.
- ,
f i l l R e c t O H
. 7.5,
, -
\Code\Listing7_3\src.
i

/**

7 . 5

Main Draw

*/
import javax.microedition. Icdui . * ;
import javax.microedition. midlet . * ;
public class Main extends MIDlet implements
CommandListener

{
//
private Command exitMidlet = new Command (" ",
Command . EXIT , 0 ) ;
public void startAppO

{
// Draw
Draw dr = new Draw ( ) ;
//
dr .start ( ) ;
//
dr. addCommand( exitMidlet) ;
dr . setCommandListener (this) ;
Display. getDisplay (this) .setCurrent (dr) ; .

public void pauseAppO {}


public void destroyApp (boolean unconditional) {}
public void commandAct ion (Command c, Displayable d)


if ( == exitMidlet)
{
destroyApp(false);
notifyDestroyed();

I**

Draw Draw.Java

*/
import javax.microedition.Icdui.*;
public class Draw extends Canvas implements Runnable
//
int position .= 10;
//
public Draw()
{ super () ,- }
public void start()
// ,
Thread t = new Thread(this);
t.start();
// run() Runnable
public void run (4.
//
while (true)

// 1
position ++;
//
repaint() ;
// 20
try { Thread.sleep(20); }
catch (Java.lang.InterruptedException zxz) {}

||

public void paint(Graphics g)


//
int x = g.getClipWidthf);
int - g.getClipHeight ;
//
g.setColor(Oxffffff);
//
g.fillRect(0,b,x,y);
//
g.setColor(0, 0, 200);
//
g.fillRect(position,40, 20, 20);

7.5 Main Draw,


Main.java Draw.Java. Main
dr Draw.
start ( ) , dr. Draw , . Draw,
, .
X,
, , X.
f i l l R e c t ( ) X
Y .
X , . /
7.5 Draw Canvas, paint ( )
run ( ) Runnable. run ( )
, .
Draw position,
X .
Draw super ( ) Canvas.
start ( ) , run ( ) . , . , 7.5,
, while run ( ) .
run ( ) , position ,
X .


paint ( ) :
int = g . g e t C l i p W i d t h ( ) ;
int = g . g e t C l i p H e i g h t ( ) ;
g.setColor(Oxfff'fff) ;
g.fillRect(0,0,,);
(clipping) . ,
,
.
X,
. : ,
. Java 2 ME , : g e t C l i p W i g t h f ) getClipHeight { ) , getC l i p X ( ) n g e t C l i p Y ( )
. ,
. . getClipWigth (') getClipHeight ( ) ,
. setColor ( ) :
g . f i l l R e c t t 0, 0, , )';
paint ( ) :
g.fillRect(position, 40, 20, 2 0 ) ;
, ' , position,
.
7.5, .
while. run ( )
, .
Draw, :
boolean z;
start ( ) true.
public void start()

"

. - true;
Thread t = new T h r e a d ( ) ;
t. start ( ) ' ;
}

run ( ) z
while.
while(z)
{
II
}
stop Draw, z false.
public void stop() { z = f a l s e ; }
Main destroyApp ( ) :
public void destroyApp(boolean unconditional)
{

Z.StOpO ;

7.9.

7.5
X . , , , .
7.5, ,
, ,
, . , ,
. end getwidth ( ) (
).
int end = g e t w i d t h ( ) ;
run { ) whi 1
:
if (position > end)
{
position = 0;


, , . 7.6 ,
- \Code\Listing7_6.
/**
7 . 6
Main luiacq.Draw
*/
import javax.microedition. Icdui . *; .
import javax.microedition.midlet . *;

public class Main extends MIDlet implements


GommandListener
{
/ /
private Command exitMidlet = new Command (" ",
Command . EXIT , 0 ) ;
public void startAppO
{
// Draw
Draw dr = new Draw ( ) ;
//
dr. start ( ) ;
//
dr . addCommand (exitMidlet ) ;
dr.setCommandListener (this) ;
Display .getDi splay (this) . setCurrent (dr) ;
public void pauseAppO {}
public void destroyApp (boolean unconditional) {}
public void commandAction (Command c, Di'splayable d)
{
if (c == exitMidlet)
{
destroyApp (false) ;
n6tifyDestroyed ( ) ;


Draw Draw.Java

*/
import javax.microedition.Icdui.*;
public class Draw extends Canvas implements Runnable
{
// '
int position' = 10;
// '
int end = getWidth();
//
public Draw()
{ super(); }
public void start ()'
{
//
Thread t = new Thread(this);
t.start() ;
}
// run Runnable
public void run()
{
//
while (true)
{
//
if(position > end)
{
//
position = 0;
}
// 1
position ++;
//
repaint();
// 20
try { Thread.sleep(20); }
catch (Java.lang.InterruptedException zxz) {}


public void paint(Graphics g) ,
{
//
int x = g.getClipWidth();
int = g.getClipHeight();
//
g.setColorfOxffffff) ;
//
g.fillRect(0,0,,);
//
g.setColor(0, 0, 200);
//
g.fillRect(position,40, 20, 20);

7.10.
7.9 ,
.
, ,
. , , .
. . 7.7, . Main.java Draw.java.

**
7 . 7
Main Draw
*/
import javax.microedition.Icdui.*;
import javax.microedition.mi.dlet. *,
public class Main extends MIDlet implements
CommandListener
{
//
private Command exitMidlet = new Command("",
Command.EXIT, 0) ;
public void startAppO


// Draw
Draw dr = new Draw ( ) ;
//
dr. start () ;
/ /
dr . addCommand(exitMidlet ) ;
dr .setcommandListener (this) ;
Display .getDisplay (this) . setCurrent (dr) ;

public void pauseApp ( ) {}


public void destroyApp (boolean unconditional) {}
public void commandAction (Command c, Displayable d)
{
if (c == exitMidlet)
{
destroyApp (false) ;
notifyDestroyed( ) ;

/**
Draw Draw. Java
v
*/

import javax. microedition. Icdui .*; .


public class Draw extends Canvas implements Runnable
{
//
int position = 0 ;
//
int endX = getWidth ( ) ;
/ /
public Draw()
{ super ( ) ; }
, '
public void start ()
{
//
.Thread t = new Thread ( thi s );


t. start() ;
// run Runnable
public void run()
//
while (true)
//
if(position > endX)
//
position = endX;
// -1
position ++;
//
repaint();
// 20
try { Thread.sleep(20); }
catch (Java.lang.InterruptedException zxz) {}

public void paint(Graphics g)


{
//
int x = g.getClipWidthO ;
int = g.getClipHeight();
.//
g.setColor(OxffffOO);
//
g.fillRect(0,0,,);
//
g.setColor(, , 200);
//
g.fillRect(position, 40, 20, 20);
//
g.setColor(250, 0, 0) ;
//
g.fillArc(position, 10, 20, 20, 45, 360);

- \Code\
Listing7_7\src. Main.java Draw, . Draw.java
Draw. position, . , .
, getwidth ( ) .
int endX = g e t w i d t h ( ) ;
endX .
Draw
Canvas. run() while if
.
if
.{

(position > endX)


position = endX;

'}

endX, - ,
position. .
. ,

. ,
7.7, - ,
. ,
.
, .

7.11.

, ,
- , . key Pressed ( )
. keyPressed ( ) , getGameAction ()
.

1IIIIHHM

switch keyPressed ( ) :
protected void key Pressed (int keyCode)

//
int act = getGameAction(keyCode) ;
/ /
switch (act )

{
case Canvas. LEFT:
/ /
break ;
case Canvas. RIGHT:
//
break;
case Canvas. UP:
//
break;
case Canvas. DOWN:
//
break;
default :
break;

,
. 7.5,
, . , posit ionX positionY,
.
int positionX = g e t w i d t h ( ) / 2 ;
int positionY = getHeight ( ) /2 ;

positionX positionY ,
. , , . 7.8 ,
- \Code\Listing7_8\src.
/**
-7 . 8


Main Draw
*/.','..
import javax.microedition.Icdui.*;
import javax.microedition.midlet.*;
public class Main extends4 MIDlet implements
CommandListener
(
{
//
private Command exitMidlet = new Command(,
Command.EXIT, 0);.
public void startAppO
{
// Draw
Draw dr = new Draw.();
//
dr.start();
//
dr.addCommand(exitMidlet);
dr.setCommandListener(this);
Display .getDisplay (this) .setCurrent (dr) ,-

public void pauseApp() {}


public void destroyApp(boolean unconditional){}
public void commandAction(Command c, Displayable d)
if (c == exitMidlet)
{
destroyApp(false);
notifyDestroyed();
}
}

/**
Draw Draw.j.ava

*/

import javax.microedition. Icdui.. *;

-V


public class Draw extends Canvas implements Runnable
{
//
int positionX = getwidth( ) /2;
//
int positionY = getHeight ( ) /2;
//
public Draw ()
{. super ( ) ; }
public void start ()
{
/.
//
Thread t = new Thread ( thi s );
t.. start () ;
}
// run Runnable
public void run ()
{
// .
. while (true)
{
/ /
repaint ( ) ;
// 20
try { Thread. sleep (20).; }
catch (Java. lang.InterruptedExcept ion zxz) {}

public void paint (Graphics g)


{
//
int x = g.getClipWidthO ;
int = g.getClipHeight ( ) ;
//
g. setColor (Oxffffff) ;
/ /
g.fillRect (0,0,,) ;
//
g. setColor (, , 200);
//
g. fillRect (positionX, positionY, 20, 20);

protected void keyPressed(int keyCode)

//
int speed = 3;
//
int act = getGameAction(keyCode) ;
//
switch (act)
{
//
case Canvas. LEFT:
i positionX -= speed;
break;
//
case Canvas . RIGHT :
positionX += speed;
break;
//
case Canvas. UP:
positionY -= speed;
break;
//
case Canvas. DOWN:
positionY += speed;
break;
default:
break;

,
MIDP 2.0 ,
.

8.
.
Java. , Java 2 ME
. MIDP 1.0
, , . MIDP 2.0 ,
, :
,
Q GameCanvas , ;
Q Layer - ,
;
Q LayerManager - ;
Q Sprite - ;
Q TiledLayer .
MIDP 2.O.
Siemens MIDP 1.0, com.siemens.mp.colqr_game.
Siemens MIDP Expert Group ,
, Siemens
MIDP 2.O.
* MIDP 2.0, . , . , , ,
, , . , . , LayerManager . , ,
, .
, ,

MIDP 2.O.

8.1. GameCanvas
GameCanvas . ,
. run ( )
Runhable.
, GameCarivas, Canvas.
Canvas , .
, - ,
.
, GameCanvas , .
public void run ( )
{
. Graphics g = getGraphics ( ) ;
while (true)
{
// ,
inputKey ( ) ;
// ,
GameGraphics ( ) ;
// / .

f lushGraphics ( ) ;
}

,
.
. -,
, f lushGraphics ( ) . , , ,
, .
getKeyState ( ) . . .
:
Q static int DOWN_PRESSED - ;
Q static int FIRE_PRESSED.- ;

Layer
Q
Q
Q
Q
Q
Q
Q

static
static
static
static
static
static
static

int
int
int
int
int
int
int

GAME_A_PRESSED - ;
GAME_B_PRESSED - ;
GAME_C_PRESSED - ;
GAME_D_PRESSED - D;
LEFT_PRESSED - ;
RIGHT_PRESS'ED - ;
UP_PRESSED - .

, , getKeyStates ( ) GameCanvas, ,
.
GameCanvas:
! void f lushGraphics ( ) - ;
Q void flushGraphics(int x, int y , int width, int height)
;
Q protected Graphics getGraphics ( ) - GameCanvas;
Q int getKeyStates ( ) . ;
G void paint (Graphics g) , GameCanvas.
GameCanvas , ,
.

8.2. Layer
Layer
.
Layer TiledLayer Sprite. Layer paint ( )
,
, Graphics.
Layer .
Q int getHeight ( ) - ;
int getwidth ( ) - ;
int getx ( ) - ;
Q int getY ( ) - ;
Q void move (int dx, int dy) - dx dy ;
Q abstract void paint (Graphics g) - ;
Q void setPosition ( i n t x, int ) - , .

. LayerManager.
G LayerManager ( ) - .
:
void append (Layer 1) - ;
Q Layer getLayerAt (int index) - ;
V

8.3. TiledLayer
TiledLayer . . 8.1.


int getSize ()- ;
void insert (Layer I, int index) -
;.
Q void paint (Graphics g, int x, int ) -
;
Q void remove (Layer 1) - .
, : , , . , LayerManager append ( ) . :
La'yerManager 1m = new LayerManager ( ) ;
1m.append(fon);
1m.append(igrok);
1m.append(prep); ,
1m.append(artf);

! .

8.5. Sprite
Sprite
TiledLayer. TiXedLayer _ , Sprite
, , , , ,
. , , . , .
, , . . , . ,
Sprite.
Sprite
Sprite.
Q Sprite (Image image) - ;
Q Sprite(Image image,-int frameWidth, int frameHeight)- , ;
Sprite (Sprite s) .
,
Sprite.
Q boolean coll'idesWithtSprite s, boolean pixelLevel) - ;
G boolean collidesWith(TiledLayer t , boolean pixelLevel) ,
TiledLayer;


Q
Q
Q
Q

int getFrame ( ) - ;
void next Frame () ;
void paint (Graphics g) - ;
void prevFrame () . ;
void setFrame(int sequencelndex)- ;
void setFrameSequence (int [ ] sequence) - ;
void setImage(Image img, int frameWidth, int frameHeight) ;
void setTrans form (int transform) -
.
Q public void defineReferencePixel (int x, int )
, .

def ineReferencePixel ( ) ,
? , , ,
. , ,
, ,
. ,
, .
def ineReferencePixel ( ) , :
I
defineReferencePixel(frameWidth / 2, frameHeight / 2 ) ;
' s e t T r a n s f o r m ( ) ,
:
Q static int TRANS_MIRROR;
Q
Q
Q
Q

static
static
static
static

int
int
int
int

TRANS_MIRROR_ROT180;
TRANS_MIRROR_ROT270;
TRANS_MIRROR_ROT90;
TRANS_NONE;

a static int TRANS_ROT180;


D static int TRANS_ROT270;
D s t a t i c int TRANS_ROT90.

. 8.2,
.
GameCanvas, Layer, Sprite, TiledLayer LayerManager, .

8.6.
Ti ledLayer ,
, ,

TRANS.MIRROR

TRANS_MIRROR_ROT180

LayerManager, . .
fon.png.
15x15 .
8.1 .
,
.

/**
TRANS.ROT90

TRANS_MIRROR_ROT90

TRANS_HIRROR_ROT270

. 8.2.

8.1
MainGame
*/
import
javax.micro-edition. Icdui . *;
import
javax.microedition.midlet.*;

public class MainGame extends


MIDlet implements CommandListener
{
//
private Command exitMidlet = new Command("",
Command.EXIT, 0) ;
// MyGameCanvas
private MyGameCanvas mr;
public void startAppO
{
//
try{
// MyGameCanvas
mr = new MyGameCanvas();
//
mr.start();
//
mr.addCommand(exitMidlet);
mr.setCommandListener(this);
//
Display.getDisplay(this).setCurreht(mr);
}catch (Java.io.lOException zxz) {};


public void pauseApp ( ) {}
public void destroyApp (boolean unconditional)
{
//
if(mr != null) mr.stopO;

public void oiranandAct ion (Command c, Displayable d)


{
if (c == exitMidlet)
{
destroyApp ( f a l s e ) ;
notifyDestroyed( ) ;

/**
MyGameCanvas.j ava
MyGameCanvas
'*/
import java.io.IOException;
import javax.microedition.Icdui.*;
import javax.microedition.Icdui.game.*;
public class MyGameCanvas extends GameCanvas implements
Runnable
{
// TiledLayer
private TiledLayer fonPole;
// LayerManager
private LayerManager 1m;
//

boolean z;
public MyGameCanvas() throws lOException
{
// Canvas
super(true);
// fonPole
fonPole = Fon();
//
1m = new LayerManager();

HHHIS

// fonPole
1m. append ( fonPole) ; .

public void start (.)


{
z = true;
//
Thread t = new Thread (this) ;
t. start () ;
}
//* , TiledLayer'
*/
public TlledLayer Fon () throws lOException
{
//
Image im = Image. createlmage (" /fon.png" );
// TiledLayer
fonPole = new TiledLayer (/**/10 , /**/10 ,
/**/1, /* * /15 , /**/15) ;
//
int[] pole =
{
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1, 1, 5, 5, 5, 5, 5, 5, 5, 5,
1, 1, 1, 1, 5/5, 5, 1, 1, 5,
1, 1, 1, 1,- 1, 5, 5, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, , 6,
1, 1, 1, 1, 1, 1, , 6, 6, ,
2, 4, 4, 4, 4, 4, 3, 3, 3, 3,
2, 2, 2, 4, 4, 4, 3, 3, 3, 3,
2, 2, 2 4, 4, 4, 3, 3 , 3 , 3,
};

/ / ,
for(int i, = 0; i < pole . length; i++)
{
/*
im*/
fonPole. setCellfi % 10, i / 10, polefi]);
}
return fonPole;

public void stop(){ z = false; }


public void run()

//,
Graphics g = getGraphics ( ) ;
while (z)
{

/ /
init(g) ;
// 20
try { Thread. sleep (20) ; }
catch ( Java. lang. InterruptedException zxz) { } ;

private void init (Graphics g)


{
//
g.setColor ( O x f f f f f f ) ;
//
' g . f i l l R e c t ( 0 , 0 , getWidth( ) , getHeight ( ) ) ;
//
lm.paint(g, , ) ;
//
f lushGraphics ( ) ;

8.1 MainCanvas MyGameCanvas, MainCanvas.java MyGameCanvas.java.


MyGameCanvas.
TiledLayer Lay erManager, z.
private TiledLayer fonPole;
private LayerManager 1m;
boolean z;
fonPole TiledLayer . 1 LayerManager . z run ( ) , .
MyGameCanvas fonPole TiledLayer I'm LayerManager. fonPole


/ , fonPole Fon ( ) .
Image im = I m a g e . c r e a t e l m a g e ( " / f o n . p n g " ) ;
fonPole= new TiledLayer(/**/10,/**/10, im,
/**/15,/**/15);

fonPole TiledLayer.
. TiledLayer
. -
, , 15x15 . TiledLayer
. TiledLayer
' .
, 20x20 , 15x15
, .
Fon ( )
.
i n t [ ] pole =
{
5, 5,
1, 5,
1,1,
1, 1,
1, 1,
1, 1,
1, 1,
2,4,
2, 2,
2, 2,

5,
5,
5,
1,
1,
1,
1,
4,
2,
2,

5,
5,
5,
1,
1,
1,
1,
4,
4,
4,

5,
5,
5,
5,
1,
1,
1,
4,
4,
4,

5,
5,
5,
5,.
5,
1,
1,
4,
4,
4,

5,
5,
5,
5,
5,
1,
6,
3,
3,
3,

5,
5,
5,
1,
1,
1,
6,
3,
3,
3,

5,
5,
5,
1,
1,
6,
6,
3,
3,
3,

5,
5,
5,
5,
1,
6,
6,
3,
3,
3,

};

. . , .. -
.
15 , 10x15 = 150 . , . Fon ( )
for.


f o r f i n t i = 0; i < pole.length; i + + )
{

,
fonPole.setCell(i % 10, i / 10, p o l e [ i ] ) ;
}
setCell ( ) . - , - - .
, - ,
, , ,
, .
, , ? , , -
. , ,
. Fon ( ) , init ( ) .
g.setColor(Oxffffff);
g.fillRect ( 0 , 0, getWidthO, getHeight());
.
7, .
paint ( ) .
0,0, .
f lushGraphics ( ) , .
run ( ) .
while, getGraphics ( )
, MIDP 2.0.
MainGame.java MainGame. startApp ( )
MyGameCanvas, ,
. destroyAppO
stop ( ) MyGameCanvas.

8.7.
MIDP 2.0 . getKeyState ( )
. , MySprite Sprite. 8.2
, ,
Up, Down, Left Right .
8.2 : MainGame, MyGameCanvas MySprite,


MainGame.java, MyGameCanvas.java
MySprite.java.
/**
8 . 2

MainGame
*/
import javax.microedition. Icdui . * ;
import javax.microedition.midlet . * ;
public class MainGame extends MIDlet implements
CommandListener
{
//
private Command exitMidlet = new Command ( "" ,
Command . EXIT , 0 ) ;
// MyGameCanvas
private MyGameCanvas mr;
public void start App()
{
'/I
try{
/ / MyGameCanvas
mr = new MyGameCanvas ( ) ;
//
mr .start ( ) ;
//
mr . addCommand (exitMidlet ) ;
mr. setcommandListener (this) ;
//
Display .getDisplay (this) .setCurrent (mr) ;
}catch ( Java. io. lOException zxz) { } ;
public void pauseApp ( ) {}
public void destroy App( boo lean unconditional)
{
//
if(mr != null) mr.stopO;
public void commandAct ion (Command c, Displayable d)


if ( == exitMidlet)
{
destroyAppf false) ;
notifyDestroyed ( ) ;

/**
MyGameCanvas . Java
MyGameCanvas
*/

import j ava . io . * ;
import javax.microedition. Icdui .*;
import javax.microedition. Icdui .game. * ;
public class MyGameCanvas- extends GameCanvas implements
Runnable
{
// MySprite
private MySprite bol;
// LayerManager
private LayerManager 1m;
/7
boolean z;
public MyGameCanvas () throws lOException
{
// Canvas
super (true) ;
//
Image im = Image. createlmage (" /bol .png" );
. // bol
bol = new MySprite (im, 23, 23);
//
bol.setPosition(getWidth() /2 , getHeight ( ) /2) ;
//
1m = new LayerManager ( ) ;
// bol
1m. append (bol) ;
public void start ( )

I
I
I
I
i

z = true;
//
Thread t = new Thread (this) ;
.' t. start ();
}
//
public void stop(){ z = false; }
public void run ( )
{
//
Graphics g = getGraphics ( ) ;
while (z)
{
/ /
inputKey ( ) ;
//
init (g) ;
// 20
try { Thread. sleep (20 ); }
catch ( Java. lang. JnterruptedExcept ion zxz) {};

private void inputKey ( )


{
//
int keyStates = getKeyStates ( ) ;
/ /
if ((keyStates & LEFT_PRESSED) != 0) bol .moveLeft ( ) ;
/ /
if ((keyStates & RIGHT_PRESSED) != 0) bol.moveRight ( ) ;
//
if ( (keyStates & UP_PRESSED) != 0) bol .moveUp ( ) ;
//
if ((keyStates & DOWN_PRESSED) != 0) bol .moveDown( ) ;
private void init (Graphics g)
{
//
g.setColor(Oxffffff) ;
//


g.fillRect(0, 0, getwidth ( ). , getHeightO)
// 0,0
1m. paint (g, 0 , 0) ;
//
f lushGraphics ( ) ;

/**
My Sprite. Java
MySprite
*/
import javax.microedition. Icdui . *;.;
import javax. microedition. Icdui .game. *;
public class MySprite extends Sprite ,
{
/ /
public MySprite (Image image, int fw, int fh)
(
//
super(image, fw, fh) ;
>
// Left
public void moveLef t ( )
{
//
move (-1,0) ;
}
// Right
public void moveRightO
{'
//
move (1,0) ;
}
// Up
public void moveUp ( )
{
/ /
move ( 0 , - 1 ) ;
}
// Down
public' void moveDown ( )

.//
move(0,1);

MySprite.java MySprite, . MySprite


Sprite.
super(image, fw, fh);
,
. , ,
,
, ,
. ,
Sprite.
moveLeft ( ) ,
moveRight (.), moveUp () moveDown ( ) ,
move ( ) . move ( ) - X
Y. 1, 2, 3 ,
.
MyGameCanvas , 8.6,
,
. MyGameCanvas
bol.png, . 23x23
. bol MySprite
bol = new MySprite(im, 23, 2 3 )
bol.png, MyGameCanvas

setPosition ( ) . append ( ) .
r u n ( ) .
init ( )
, inputKey ( ) .
private void inputKey()
{
int keyStates = g e t K e y S t a t e s ( ) ;
if ((keyStates & LEFT_PRESSED) >.= 0) bol .moveLeft ( ) ;
if ((keyStates & RIGHT^PRESSED) != 0) bol.moveRight();
if ((keyStates & UP_PRESSED) != 0) b o l . m o v e U p ( ) ;
if ((keyStates & DOWN_PRESSED) ! = - Q ) bol.moveDown();

(IIIII

inputKeyO getKeyState ( ) . inputKey ( ) if , moveLeftO', moveRight ( ) , moveUpO moveDown ( )


.
MainGame MainGame.java MyGameCanvas, .
bol.png
23x23 .
, ,
.

8.8.

. , Java 2 ME .
,
. . 8.3, .

. 8.3.
. 8.3 ,
, .
, .
.
, ,
, .
. Java 2 ME
Sprite.
nextFrame ( ) ^
. ,
, .
, . 8.3. ,
, .


8.3, - \Code\Listing8_3\src .
/**

8 . 3
MainGame
. */
import javax.microedition.lcdui . *;
import javax. microedition.midlet , *;
public class MainGame extends MIDlet implements
CommandListener
{' '
/ /
private Command exitMidlet = new Command (,
Command . EXIT , ;
// MyGameCanvas
private MyGameCanvas mr;
public void startApp()
{
//
try{
// MyGameCanvas
mr = new MyGameCanvas ( ) ;
//
mr. start ( ) ;
//
mr . addCommand ( exitMidlet) ;
mr .setCommandListener (this) ;
//
Display. getDisplay (this) . setCurrent (mr) ;
} catch ( java.io. lOException zxz) { } ;
public void pauseApp ( ) {}
public void destroyApp (boolean unconditional)
{ //
if.(mr != null) mr.stopO;
public void commandAct ion (Command c, Displayable d)


if ( == exitMidlet)

destroy App( false) ;


notifyDestroyed ( ) ;

/** .
MyGameCanvas . j ava
MyGameCanvas
*/

import java.io.*;
import javax. microedit ion. Icdui . *;
import javax .microedition . Icdui . game . * ;
public class MyGameCanvas extends GameCanvas implements
Runnable

{
// MySprite
private Matros matros;
// / LayerManager
private LayerManager 1m;
//
boolean z;
public MyGameCanvas () throws lOException
{
// Canvas
super (true) ;
//
Image im = Image. createlmage (/matros. png) ;
// matros
matros = new Matros(im, 94, 100);
//
matros. setPositionf 30 , 30);
, //
1m = new LayerManager ( ) ;
//
' 1m . append (matros ) ;
public void start ()


z = true;
//
Thread t = new Thread (this );
t .start ( ) ;

}
//
public void stop(){ z = false; }
.public .void 'run()
{ '
/
Graphics g = getGraphics ( ) ;
while (z)
{
/ /
init (g) ;
//
try { Thread. sleep (250 ); }
catch (Java. lang. InterruptedException zxz) {}

private void init (Graphics g)


{
// g.setColor(Oxffffff ) ;
//
. g.fillRect (0, 0, getWidthO, getHeight ( ) ) ;
// 0,0
1m. paint (g, 0 , 0) ;
//
matros .Animation ( } ;
//
f lushGraphics ( ) ;

' /**

' . .

Matros.Java
Matros
*/

import javax.microedition.Icdui.*;


import jayax.microedition. Icdui .game . * ;
/
public class Matros extends Sprite
{
/ /
public Matros (Image image, int-fw, int fh)
{
//
super (image, fw, fh) ;
}
/
public void Animation ()
{
//
next Frame ( ) ;

8.3 . Matros, Sprite, Animation ( ) , :


public void Animation ( )
{
next Frame ( ) ;
}
Animation ( )
. MyGameCanvas Matros:
private Matros matros;
MyGameCanvas matros.
Image im = Image. createlmage (/matros .png) ;
matros '= new Matros (im, 9 4 , 1 0 0 ) ;
94x100 , .
, setFrame ( )
. Graphics ( )
MyGameCanvas Animation ( ) :
matros .Animation ( ) ;
' . 8.3 .
.

8.9.

. MIDP 2.0 , .
Sprite.
Q collidesWith(Image image,' int x, int y , Boolean pixelLevel) - ;
Q collidesWith{ Sprite s, Boolean pixelLevel) - Sprite;
Q collidesWith(TiledLayer t, Boolean pixelLevel) - Sprite
TiledLayer.
, . , - ,
. , ,
. . Sprite
. nextFrame ( ) , 8.8,
.
Q prevFrame () - . nextFrame { ) ,
;
Q setFrameO -
.
Q setFrameSequence {) - ;
getFrame ( ) - , ;
Q set Image (). - . , , ,
.

. . , nextFrame ( ) , prevFrame ( ) , setFrame ( ) setFrameSequence ( ) .
,
.
MySprite, Sprite. ,
, -


nextFrame ( ) , prevFrame ( ) , setFrame ( ) setFrame'Seguence ()
, .

23x23 . , . . ,
, ,
.
8.4 - \Code\
Listing8_4\bin\Listing8_4.jad ,
MIDP 2.0. 8.4 (
- \Code\Listing8_4\src) . , ,
.
. ,
, , , . 8.4 .
/**
8.4
MainGame

*/

import javax.microedition.Icdui.*;
import javax.microedition.midiet.*;
public class MainGame extends MIDlet implements
CommandListener

{
//
private Command exitMidlet = new Command(,
Command.EXIT, 0);
// MyGameCanvas
private MyGameCanvas mr;
public void startAppO

<{
//

try{
// MyGameCanvas
mr = new MyGameCanvas();
//
mr.start() ;
//


mr . addCoimand ( exitMidlet ) ;
mr .setcommandListener (this) ;
/
Display .getDisplay (this) .setCurrent (mr) ;
} catch (Java. io. lOExcept ion zxz) { } ;

public void pauseAppO {}


public void destroyApp (boolean unconditional)
{
//
if(mr != null) mr.stopO;

public void comm'andAct ion (Command c, Displayable d)


{
if (c == exitMidlet)
{
destroyApp (false) ;
notifyDestroyed( ) ;

/**
MyGameCanvas . j ava
MyGameCanvas
*/

import java.io. * ;
import javax.microedition. Icdui . *;
import javax.microedition. Icdui .game. * ;
public class MyGameCanvas extends GameCanvas implements
Runnable
{
// MySprite
private MySprite bol ;
// LayerManager
private LayerManager 1m;
//
private MySprite bombal , bomba2 , , bomba4;
//
boolean z;


public MyGameCanvas() throws lOException
// Canvas
super(true);
//
Image bollmage = Image.createlmage(/bol.png);
// bol
bol = new MySprite(bollmage, 23, 23);
//
bol.setPosition(getwidth()/2, getHeight/2);
// ,
Image bombalmage = Image.createlmage(/bomba.png);
//
bombal = new MySprite"(bombaImage, 23, 23);
//
bombal.setPosition(10, 10);
//
bomba2 = new MySprite(bombalmage, 23, 23);
//
bomba2.setPosition( getwidth()-30, 10);
//
= new MySprite(bombalmage, 23, 23),
//
. setPosition (10 , getHeight () -4-0) ;
//
bomba4 = new MySprite(bombalmage, 23, 23);
// '
bomba4.setPosition(getwidth()-30, getHeight()-40);
//
1m = new LayerManager();
//
1.append(bol);
//
1.append(bombal);
1.append(bomba2);
1.append();
1. append (bomba4) ,//
public void stolknovenie()
//
if(bol.collidesWith(bombal, true))


bol . next Frame ( ) ;
bombal . nextFrame ( ) ; .

}
//
if (bol .collideswith (bomba2 , true))
{
bol .prevFrame ( ) ;
bomba2 . prevFrame ( ) ;
}
//
if (bol .collideswith ( , true) )'
{
bol .setFrame (2) ;
. setFrame ( 0 ) ;
}
//
if (bol .collideswith (bomba4 , true) )
{
int[] i = {2,3};

bol . setFrame ( 0 ) ;
bomba4 . setFrameSequence ( i ) ;

public void start ()


{
z = true;
//
Thread t = new Thread(this) ;
t. start () ;
}
// '
public void stop(){ z = false; }
public void run()
{
//
Graphics g = getGraphics ( ) ;
while (z)
{
//
stolknovenie ( ) ;
//
input Key ( ) ;

HIIIHH

//
init(g) ;
// 20
try { Thread. sleep (20 ) ; }
catch (Java. lang. InterruptedExcept ion zxz) { } ;

private void inputKey ( )


{
//
int keyStates = getKeyStates ( ) ;
//
if ((keyStates & LEFT_PRESSED) != 0) bol.moveLeft ( ) ;
//
if ((keyStates & RIGHT_PRESSED) != 0) bol .moveRight ( ) ;
//
if ((keyStates & UP_PRESSED) != 0) bol'.moveUp ( ) ;
//
if ((keyStates & DOWN_PRESSED) != 0) bol .moveDown( ) ;

>

I
I

private void init (Graphics g)


{
7/
g.setColor(OxffffOO) ; ,
//
g.fillRect (0, 0, getWidthO, getHeight ( ) ) ;
// 0 ,
1m. paint (g, 0, 0) ;
//
f lushGraphics ( ) ;

/**
MySprite . j ava
MySprite
*/
import javax.microedition. Icdui . *;
import javax.microedition. Icdui .game. *;
public class MySprite extends Sprite -


//
public MySprite(Image image, int fw, int fh)
{
//
super(image, fw, fh) ;
}
//
public void moveLeft()
{
//
move (-1,0) ,}
//
public void moveRight()
{
//
move(1,0);
}
//
public void moveUp()
{
//
move(0,-1);
}
//
public void moveDown()
{
//
move(0,1);
}

8.4 MainGame, MyGameCanvas


MySprite.
MyGameCanvas,
.
MyGameCanvas
bol.png, bol, MySprite
bol.
Image bollmage = Image.createlmage (/bol .png) ,bol = new MySprite(bollmage, 23, 2 3 ) ;
bol. setPosition(getWidth ( ) /2 , getHeight ( ) / 2 ) ,-

11111111

, ,
,
.
, def ineRef erencePixel ( ) .
MyGame'Canvas .
Image bombalmage = Image.createlmage(/bomba.png);
bombal, bomba2,
bomba4 MySprite
.
bombal = new MySprite(bombalmage, 23, 2 3 ) ;
bombal.setPosition{10, 1 0 ) ;
bomba2 = new MySprite(bombalmage, 23, 2 3 ) ;
bomba2.setPosition( g e t w i d t h ( ) - 3 0 , 1 0 ) ;
= new MySprite(bombalmage, 23, 2 3 ) ;
.setPosition(10, g e t H e i g h t ( ) - 4 0 ) ;
bomba4 = new MySprite(bombalmage, 23, 2 3 ) ;
bomba4 . set Posit ion (getWidth ( ) -30 , getHeight ( ) -40) , .

MySprite, .
1m.append(bo1) ;
1. append (bombal) ,1.append(bomba2);
1m.append();
1m. append(bomba4);
- ,
stolknovenie ( ) , if/
else bol bombal-bomba4. , - 8.4, \Code\Listing8_4\bin\Listing8_4.jad
. , .
, ,
next Frame ( ) . ,
.
.
, ,
. ,



nextFrame ( ) .
, ,
(,
prevFrame ( ) , ,
. .

set Frame ( ) .

. .
bol.setFrame(2);
.setFrame(0);
, ,
,
. ,
0", .
setFrameSequen ( ) ,
.
, ,
, .
, .

9.
-
.
- 30-40% ! , , , ,
,
. , , . ,
.
MIDP 1.0 , ,
. MIDP 2.0 , (MMAPI),
, :
Q Nokia (Specification Lead);
Q Aplix Corporation;
Q Beatnik, Inc.;
Q France Telecom;
Q Insignia Solutions;
Q Mitsubishi Electric Corp.; '
Q Motorola;
Q Netdecisions Holdings United;
Q NTT DoCoMo, Inc.;
Q Openwave Systems Inc.;
Q Packet Video Corporation;
a Philips;
Q Siemens AGICM MP TI;
Q Smart Fusion;
Q Sun Microsystems, Inc.;
Q Symbian Ltd;
Q Texas Instruments Inc.;
Q Vodafone;
Q Yamaha Corporation;
Q Zucotto Wireless.
-,
, :

Mobile Media API -


. , , ;
Q MIDP 2.0 Media API - .
MIDP 2.0
Media API,
MIDP 2.O.
:
- ,
.
. MIDP 2.0
Manager;
Q - Player;

Manager, MIDP 2.0 Media API, :
Q javax.microedition.media;
Q javax.microedition.media.control.
Manager. MIDP 2.0 Media API,
, Manager . , ,
, .

9.1. javax.microedition.media
javax.microedition.med.ia
, .

9.1.1. Control
Control - , , ToneControl VolumeControl.

9.1.2. Controllable
Controllable
, :
Q Control getControl (String controlType) - ;
Q Control [ ] getControls ( ) - .

javax.microedition.media

9.1.3. Player
Player Controllable
. createPlayer { )
Manager, :
Player playerl = Manager.createPlayer();
,
Player.

Player
Q void addPlayerListener (PlayerListener playerListener') ;
Q void c l o s e t ) - ;
Q void deallocate () - , ;
Q String getContentType ( ) - ;
Q long getDuration() - ;
Q long getMediaTime ( )
;
Q int g e t s t a t e ( ) ;
G void
removePlayerListener(PlayerListener
playerListener) - ;
Q void setLoopCount (int count) - ;
long setMediaTimedong now) - ;
void start ( ) - ;
Q void stop ( ) - .
,
9.3 Player.

9.1.4. PlayerListener
PlayerListener
. 5 CommandListener? PlayerListener
, . PlayerListener :
Q void playerUpdate(Player player, String event, Object
eventData) - .
Player playerUpdate ( ) , eventData event:
Q static String CLOSED - ;

-
Q static String DEVICE_AVAILABLE - ;
static String DEVICE_UNAVAILABLE -
;
"static String DURATION_UPDATED - ;
Q static String END_OF_MEDIA -
;
Q static String ERROR - ;
static String STARTED - ;
Q static String STOPPED - ;
Q static String VOLUME_CHANGED -
.

9.1.5. Manager
Manager ,
, .
static Player createPlayer(InputStream stream, String
type) -
;
Q s t a t i c Player createPlayer(String locator) - ;
D static String[] getSupportedProtocols(String content_type) - ;
Q static void playTone(int note, int duration, int volume)
.

9.2. javax.microedition.media.control
javox.microedition.media.control ,
. 9.4 .

9.2.1. ToneControl
ToneControl
. void setSequence (byte [ ] sequence), :
Q static byte BLOCK_END - ;
Q static byte BLOCK_START - ;
Q s t a t i c byte C4 - ;
Q s t a t i c byte PLAY_BLOCK - ;
static byte REPEAT - ;

wav-
Q static byte SET_VOLUME - ;
Q static byte SILENCE - ;
Q static byte TEMPO - ;
Q static byte VERSION - .
, 9.4.

9.2.2. VolumeControl
VolumeControl , :
Q int getLevel ( ) - ;
boolean isMutedO - ;
int setLevel (int level) - . 0 100;
Q void setMute (boolean mute) - .
, ,
javax.microedition.media javax.microedition.niedia.control.
, .

9.3. wav-
wav- . Wav- . . '
J2ME Wireless Toolkit 2.1, wav- res. ,
, wav- J AR, .
wav-
InputStream , wav, :
InputStream input =
getClass ( ) . getResourceAsStream(<aii .wav) ;
:
Player player = Manager.createPlayer(input,' audio/X-wav);
createPlayerQ Manager. . startQ wav-.
9.1 , wav- JAR-.
Form, , -

-
: wav-.
WavPIay ( ) , wav-. .

/**
9 . 1
WavMIDlet
/'
wav-
*/
import javax.microedition. Icdui . * ;
import javax.microedition.midlet . * ;
import javax.microedition. media. *;
import javax.microeditionlmedia. control . * ;
import java.io.*;
public class WavMIDlet extends MIDlqt implements
CommandListener
{
/ /
private Command exitMidlet = new Command ( "" ,
Command . EXIT , 0 ) ;
//
private Command pi' = new Command ( "" , Command. OK, 1) ;
// mydisplay
private Display mydisplay;
public WavMIDlet ( )
{
mydisplay = Display .getDisplay (this) ;
public void startApp ( )
{
Form Is = new Form ( " wav");
//
Is . addCommand ( exitMidlet) ;
//.
Is .addCommand (pi) ;
Is . setCornmandListener (this) ;
//
mydisplay .setCurrent (Is) ;
private void WawPlay(


try {
// melod.wav
InputStream input =
getClassO.getResourceAsStream("melod.wav");
//
Player player = Manager.createPlayer(input,
"audio/X-wav");
//
player.start();
} catch (lOException zxz) {}
catch (MediaException zmz) {}
}

public void pauseAppO {}


public void destroyApp(boolean unconditional){}
public void commandAction(Command c, Displayable d)
if (c == exitMidlet)
destroyApp(false);
notifyDestroyed();

. .

if (c == pi)

WawPlay();

9.4.

, . ,
wav, mp3 .
,
wav-, . , . , ,
.
, . , -

-
, , . , , .
. .
ToneControl javax.microedition.media.control.*, 4, .
, , :
byte Re = (byte)(ToneControl.C4+1);
(
4), . ,
, . 0 127.
, ,
. , ,
, . ,
, :
byte[] Nota = {...};

.
ToneControl.VERSION, I,

, 5 127. :
ToneControl.TEMPO, 30,
, , :
ToneControl.BLOCK_START, 0,
.
,
2 16. :
byte d = 4,Re,d,Mi,d,Re,d,
. SELENCE, :
byte stop = ToneControl.SELENCE,
byte d = 4;
:


R e , d , stop, d, Mi ,d, stop,d, s t o p , d , R e , d ,
,
'> '
, BLOCKJ.END :
ToneControl . BLOCK_END , 0 ,

BLOCK_START,
BLOCK_END. .
PLAY_BLOCK .
. 9.2, , .
/**
9 . 2
TonMIDlet'

*/
import javax.microedition. Icdui . * ;
import javax.microedition. midlet . * ;
import javax.microedition. media . * ;
import javax.microedition. media. control . *;
import j ava . io . * ;
public class TonMIDlet extends MID'let implements
CommandListener
{
//
private Command exitMidlet = new Command ( "" ,
Command . EXIT , 0) ;
//
private Command pi = new Command ( "" , Command. OK, 1) ;
// mydisplay
private Display mydisplay;
public 'TonMIDlet ( )
{
mydisplay = Display .getDisplay (this) ;

public void startApp()


{
Form Is = new Form ( " ");
/ /

-
Is . addCoitimand(exitMidlet) ;
// ^
Is.addCommand(pl) ;
Is , setCommandListener (this) ;
/ /
my display . set Current (Is) .,-

private void TonPlayO


{
//
byte Do = ToneControl . C4;
//
byte Re = (byte) (ToneControl .C4 + 1) ,//
. byte Mi = (byte) (ToneControl .C4 + 2);
//
byte Fa = (byte) (ToneControl. C4 + 3);
//
byte So = (byte) (ToneControl .C4 + 4) ;
/ /
byte Lj = (byte) (ToneControl. C4 +' 5) ,//
byte Si = (byte) (ToneControl .C4 + 6) ;
//
byte stop = ToneControl .SILENCE;
//
byte speed = 30;
//
byte pr = 4;
//
byte[] Nota = {
// ,
ToneControl. VERSION, I,
//
ToneControl .TEMPO, speed,
//
ToneControl. BLOCK_START, 0,
//
Do , pr ,- stop , pr , Re , pr , stop , pr , Mi , pr , stop , pr ,
Fa,pr , stop,pr , So,pr , stop,pr ,Lj ,pr ,stop,pr , Si ,pr ,
//
ToneControl. BLOCK_END, 0,
// '


ToneControl . PLAY_BLOCK , 0 ,
};
//
try{
Player player =
Manager. createPlayer (Manager. TONE_DEVICE_LOCATOR) ;
player .realize (); .
ToneControl toncontrl =
( ToneControl) player .getControl (ToneControl) ;
toncontrl . setSequence (Nota) ;
player. start ( ) ;
} catch (lOException zxz){}
catch (MediaException zmz){}
}
public void pauseAppO {}
public void destroy App (boolean unconditional) {}
public void commandAct ion (Command c, Displayable d)
{
if (c == exitMidlet)
{
destroy App ( false) ;,
notifyDestroyed( ) ;
}
if (c == pi)
{
TonPlay ( ) ;

9.2 , wav-. TonMIDlet


Form :
. , TonPlay ( ) , , ,
.

Java 2 Micro Edition , ,


, ,
, , , . Java 2 Micro Edition - , Nokia,
Siemens, Sony Ericsson, Motorola, Samsung, Symbian, Palm Computing, Sharp, Mitsubishi, NEC .
Java 2 Micro
Edition, ,
, 2 .
, , Java 2 Micro Edition
. , : Java2ME@mail.ru. ,
,
, .

1. Java
Java (),
.
Java . , Java , , Java, . , -
AWT Swing , Java 2 Micro Edition.

1.1.
-
. , ,
. - , .
, , , . , , , ,
. .
, ,
, , .
,
. Java ,
.
, , Windows
Linux, Unix. ,
-
. : . Java , C/C++ - . ?

Java
.
, . ,
Windows, Linux .
,
. ,
, Java .
- Windows Linux, Java- Java ,
.
- Java,
,
. ,
3. , Java.

1.2. -

Java , -
. . ,
, - .
-
. ,
-, . , ,
, , , .
/ . ,
- . , , , .
, .
.
-
. , . - , ,

. ,
- , -

. - . , . ,
, , . . , , -
. - , ,
, .
. ,
.

1.2.1.
Java ,
- . ,
, .
, . , , . ,
, , - ,
. , . , :
, , .
,
,
, .

. ,
.

1.2.2.
, , . ,
. ,
.

. , , ,
? ,
-

Java
. ,
. , Esc , . ,
(, -,
),
. , , , , ,
.
, ,
: ' , ,
, . Java
.

1 .3. Java 2 ME
,
.
, , ,
.
, , ,
.
, , ,
: .
Java,
.

{.
( )

{
//
}
( )

{
/ /

. ,
, , -

Java 2 ME

1111

. . . .
Java.
class T e l e f o n
{
/ void on ( )
{

// on ( )
}
void off ( )
{
// off()

class Java , . Telefon.


. , . Telefon,
telef on TELef oN . , .
, , , , .
, , .
Telefon : on ( ) -
of f ( ) - .
- , .
, - Java.
on ( ) ,
, on ( int time) on (int time, int timel) . . , on ( int time) time. ?
, , .
time . ,
.

1.3. 1.
Telef on : / /.
, -

Java
, . ,
, .
Java , : / / , /*...*/ /**...*/. , / /
:

//
!!! ! !
//
// '
// ...
//
, /*...*/ . /*, , , * /.
/**...*/
.

1.3.2. Java

, Java .
, Java - ,
. Telef on . , on (int t ime) t ime,
. ,
. int
time. Java 2 ME . . 1.1.

1,1.

byte
short
int
long
char
boolean


1
2
4
8
2

Java 2 ME Java 2 SE
, .
G byte -128 128;
D short - -32768 32767;
Q int - -2147483648
2147483647;

Java 2 ME
Q long - , -922337203685475808
9223372036854775807;
Q char - Unicode.
0 65536, 256 .
: 'G';
Q boolean - , : false - true . .
- ,
true, false. , -
( ), . , .
- :
i.nt
long
char

time;
BigTime,word;

.
:
mt

time, t i m e l , time2;

, Telefon, . on ( ) off ( ) ,
.
class Telefon
{
//S -
//w -
//h -
int w, h, S;
//
vord Area ( )
{
S = w*h;

, S, w h, , , , . Area ( )
. ,
. Area ( ) S = w*h.
, S.
Java, .

Java

1.3.3.
Java . , ,
.
*, ./, + - . %
=. :
int = 3

3. :
==. , .
int
=
=
z =

, , z;
5;
3;
0;

Z = X + ;

z , 8.
= z*x;

5,
z * (8*5), 40. ,
, :
// = 4 0 ;
// = 3;

// . z = 8;

.
, Java 2 ME
, :
X = Z / ;

:
= 8/3;

2. ,
%.
. .

Java 2 ME
++ ,
. ,
. .
.
int x = 5 ;

// 6
.
int = 5 ;
-;

/ / 4
:
int = 5;
int = 0;
= ++;

8 , 5,
. :
= 6, = 5

:
int = 3 ;
int = 0;
= ++;

, , .
.
= 4, = 4

. ==, < >,


<'= >=,
!=.
9 == 10;

, ,
false.
9 !=

10; .

, , , true.
, , .

Java
. , && , ||.
, :
* && *;

, , . , .
&& I I ,
.
I I

*;

, . , :
*

I I

* && C*D

| I

*;

, , , ? , Java,
,
, , , . Java:
[] , ., ,
!, ~, ++, '- -, + (), - (), new,
*, / , %,

<

<~ I

~ I.

> ,

&, , I ,
&&,

11,

9.

=, /=, %=, | = , = , =, =, >=.

, . .
, - .

1.3.4. main
Telefon, ,
, . Telefon . ,
Telefon. ,

Java 2 ME
.
*.java. , Telefon.java. Telef on, , , ,
. , . , ,

. Java main ( ) ,
, , .
.

public class. RunTelefon


{
public static void main( String [] args)
{
/ /

public static -
. RunTelefon main ( )
Telef on
. , , . Telef on
, RunTelefon
. RunTelefon , Telef on .
:
class Telefon
{
//
int w, h, s;
//
void Area ( )
{
S = w*h;
class RunTelefon
{
public static void main (String args [ ] )
{
/* Area ( ) .*/

Java
,
RunTelef on . , public, private protected, .

1.3.5.
public, main ( ) ,
, main ( ) main ( ) , . public
, , ,
. public, , , ? , - , , ? Java
: private protected, .
, , Java
public. main (),
public, main ( )
. ,
ma in () , , , ,
main ( ) .

1.4.
. - , , :
class Telefon
{
Telefon();
/ /
int w, h, s; //
void A r e a ( ) ; //
}

. ,
( Telefon ( ) ), Java ,
.
.
, , .


class Telefon
{
int w, h, s;
Tele.fon (int a, int b)
{
w = a; .

//

h = b;
}

void Area ( ) //
. {
S = w*h;

( ),
, : = 70, b = 100.
w h
Telefon. .
. ,
Telefon:
Telefon (int a, int b) ;
Telefon (char a, char b) ;
, .

1 .5.
, .
, ,
. :
Telefon object;
int , .
,
null. , ,
. , new, .
Telefon object;
object = new TelefonO;

Java

Telefon object = new T e l e f o n ( ) ;


Telefon . , .
object,
new Telefon ( ) . , .
. main ( ) Telefon,
.
class Telefon
{
int w, h, s;
// Telefon
Telefon (int a, int b)
{
w = a;
h = b;
-}

// ,
void Area ( )
{
S = w*h;
// class RunTelefon .
RunTe 1 f on . j ava
class RunTelefon
{
public static void main (String a r g s [ ] )
{
// Telefon
Telefon object = new Telefon (70, 90);
//
object .Area ( ) ;

. , Telefon
: w, h s, , , , . -


Telefon .
Area ( ) Telefon , s. RunTelef on main ( ) ,
. , main ( )
.
main( )
Telefon 70 - 90 . Area ( ) , .
Area ( ) ,
Telefon. object .Area ( ) ,
Telefon Area ( ) . Telefon, , Area ( )
Telefon, :
objectl .Area ( ) ;
object2 .Area ( ) ;
objects .Area ( ) ;
Telefon
. , Telefon, Area ( ) , return.
class Telefon
{
int w, h, s, n,/ /
Telefon (int a, int b)
{

w = a;
h = b;
}
/ /
int Area ( )
{
return w*h;

// class RunTelef on
RunTelef on . j ava
class RunTelefon
{
public static void main (String [] args)

'

Java
// Siemens
Telefon Siemens = new Telefon (101, 8 0 ) ;
1 1 nokia
Telefon nokia = new Telefon (128, 128);
// s
s = Siemens .Area ( ) ;
//
n = nokia. Area ( ) ;

Telefon Area ( ) , return.


,
.
main ( ) , s N
Telefon.
Siemens 101x80=8080, nokia 128x128=16384 .
, ? , ,
. Java print In ( ) .
Area ( ) , print In ( ) .
s = Siemens .Area ();
System. out .print In (" Siemens" + s) ;
n = nokia. Area ()
System. out .println ( " nokia" + n) , print ( ) , ,
System, , out - ,
. println ( ) , , , .
, . , + s, +,
s, .
- , - , , , ,
. , ,
. - ,
. , .

1.6.
, RunTelef on, main ( ) ,
,
. , , , , . , .
- ,
? Java .
, .
, , .
,
. , , . , , , ,
. . Java . : if /else -
. if /else :
if ()
{
// 1
'}'

else
{
// 2
}
, : ( i f )
, 1, (else) 2.
if /else , if.
if /else, :

if ( 1 )
{.
''
if ( 2 )

,
if, , -

Java
.
if , if.
Java
.

1 .7.
Java switch,
. ,
. :
switch ()
{
case 1 :
// 1
break;
case 2 :
// 2
break;
case 20:
// 20
break;
default:
//
break;
switch case, . , switch case,
. case,
, default. break, .

, break.
break,
, . break !

1 .8.
- , ? , , , -


,
. .
- . ,
. - Java ( ,
Java ), :
1) 1 ;
2 ) 2 ;
3) 3 ;
100) 100 ;

- , . , - .
Java- while,
do/white f dr. ,
for. .

1.8.1. while
while :
while ()
{
// ,
}
,
i f /el se, .
while, , {...}.
, while ,
. ,
, while.
. .
:

int i. = 0;
while (i < 1Q)
{
//

Java
i 0,
i< 10, i 10,
. i 1 . . i
while. i , 0
. , :
int i = 10;

while ( i > 0 )
{
/ /
i A
}
, . - .
while ,
f a l s e true. while , , :
boolean i = true;
while ( i )
{
//
}

i , true, whi 1 . - , i , while .


==.
:

int i =
while (i == 5)
{.
/ /

,
=, , .
int i =

while (i =' 5)


/ /

i 5, ,
, . .
i ,
while, i
, , .

1 .8.2. do/while
while
. , ,
. , while,
false, , while. . Java do/while. do/while
:

do
{
//'
}while ()
do while , , , while, . , , ,
. do /while ,
.
\

1.8.3. for
, , . for while do/while. , for:
for (int i = 0; i < 10; i++)
{
/ /
. \

for, .
: i = 0, -

Java
i < 10 i .
for, i = 0 i < 10. .
for, : i++,
. - i < 10 .
, i < 10 . for
,
, .
while ,
:
f o r - ( i n t i = 10; > 0; i-).
{

//
}
, ( ,
.

1.9.
. , , ,
. - . Java :
int[]M;

, . . new
. :
i n t [ ] M = new i n t [ 2 0 ] ;
.
[],
.
[ 0 ] = 3;
[ 1 ] = 5;
[ 2 ] = 20;

0, . , -


, ,
for, .
i n t [ ] M = new int [ 5 0 ] ;
for (int i = 0; i<5'0; i + +)

M[i]

= i;

}

49, , .
, new.
i n t [ ] M = { , 1, 2 , 3, 4}

4.
, .
, X Y . Java .
int stroka = 10;
int stolbec = 10;
i n t [ } [ ] M = -new [stroka] [stolbec];
. , .
.
:

{55 3, 8},
{7, 12, 16),
{9, 12, 14}
}
for ,
. ,
, .
:

i n t [ ] [ ] = new int [100] [50] ;


for (int i = 0; i < 100,- i + +)
for (int a = 0,- a < 50; a++)
M [ i ] [a] = 0;

, .

Java

1.10.
Java . ,
.
, , .
- ,
' . , ? Java . ,
Siemens:
class Siemens
{

int w, h;
int Area ( )
{
return w*h;

Siemens, extends:

class SiemensMSS extends Siemens


{
//
}

SiemensMSS Siemens,
Siemens SiemensMSS. SiemensMSS Siemens
: Siemens,
, public. ,
public, SiemensMSS,
Siemens. Area ( ) w h. Siemens, SiemensMSS,
.
. , , , Siemens
55 . , Nokia.
// Nokia
class Nokia


// ,
int dh, dw, ds;
// ,
int Area ( )
{
return dw * dh;

// Nokia3100
class Nokia310 extends Nokia'
{
7/ ,
int th, dw, .ds;
/ ,
int tArea ( )
{
.return tw * th;

//
class RunNokia

;|
public static. void main (String argsf])
{
//

Nokia3100 nokiaSlOO = new Nokia3100();


//
nokiaSlOO.dh = 128;
nokia.3100.dw .= 128;
nokia3100.th = 102;
nokia3100.tw = 43;
//
ds = nokia.dArea ( ) ;
//
dt = nokia. tArea ( ) ;

Nokia3100, Nokia, public. . (), . , Nokia nokiasuper = new Nokia ( ) ,

Java
,
.
& , ,
, , , , , .
, , - : NokiaSlOO,
NokiaGGOO, Nokia2100 .
. Java . ,
.

1.10.1.
. Nokia,
. .
,
.
. super. .
// Nokia
class Nokia
{
// Nokia
// Nokia
}
// NokiaSeries60
class NokiaSeriesGO extends Nokia
{
// NokiaSer.iesGO
NokiaSeriesGO(int a, int b) ;
// NokiaSeriesGO
}
// NokiaGGOO NokiaeSeriesGO
class Nokia6600 extends NokiaSeries60
{
7/ NokiaGSOO
NokiaGGOO (short f, short' b, short c)
{
super (a, b)
// .


// NokiaSlOO NokiaeSeries60
class Nokia6100 extends NokiaeSeries60
{
// Nokia6100
Nokia6100 (char a, char b)
{
super (a, b)
//
}
// Nokia6100
}
,
super . super
. super,
.
. , ,
? , , .
. super. :
// Siemens
class Siemens
{
int a, b;
}
// SiemensMC62
class SiemensMC62 extends Siemens
{
int .a, b;
// SiemensMC62
SiemensMC62 (int c, int d)

stfper.a
super. b
a = ;
b = .d;

= ,- //
= d; //
//
// b

-'

Java
super
.
, ,
super - .
Java this, . , .
Object.
Java Obj ect. extends .

1.11.
Java 2 ME . ,
, , ,
, , .
interface, - implements.
:
public interface Mylnterface
{
int Inkriment { ) ;
}
class MyOne implements Mylnterface
{
int a ;
// Inkriment () MyOne
public int Inkriment ()
{ .
. a = 9++;
return a;

class MyTwo implements Mylnterface


{
int a;
// Inkriment () MyTwo
public int Inkriment ()


a = 2 + +;

return a;

Mylnterf Incriment ( ) .
, , . MyTwo
Incriment ( ) . , , , , , .
, , ,
. , new , , .
extends, Java.

1.12.
, ,
, . package . , , , ,
1.10.1 Nokia:
package Nokia;
import , Nokia.
import Nokia . *
Nokia
. , :
import Nokia. NokiaeSeries60 .Nokia6600;
, , Nokia.
,
, .
- , - ,
. . ,
.
, . .
: ? ,

Java
... Sun Microsystems, Java,
, :
package ru.dmk;
:

package Buratino;
package Pinocchio;
. Java.
Java , . . Java 2 ME :
Q java.io;
Q java.lang;
G java.util;
G javax.microedition.lcdui;
Q javax.microedition.lcdui.game;
Q javax.microedition.io;
Q javax.microedition.media;
Q javax.microedition.media.control;
javax.microedition.pki;
G javax.microedition.midlet;
Q javax.microedition.rms.
. , , , -, .
2. ,
:
import j a v a . l a n g . *
, abs (int a ) , Math,
.

int a = 9;
int = Math.abs();
, , .
Java ,

Java 2 Micro Edition.

2.
Java 2 Micro Edition

, , , Java 2 Micro Edition. Java 2 ME, Sun Microsystems,
: http://java.sun.com. Java 2 ME, -, , SUN ONE Studio 4 Mobile
Edition J2ME Wireless Toolkit 2.1. , Java 2 ME. , , . ,
Java
2 Micro Edition.

2.1. Java.lang
Java.

2.1.1. Runnable
Q Runnable ,
.

Q void run ( ) - .

2.1.2. Boolean
- -
Boolean.

Boolean (boolean value) - Boolean.

Q boolean
booleanValue () -
Boolean;
Q boolean equals (Object obj ) - true,
Boolean;

Java 2 Micro Edition

int
hashCod'e ( ) - (-)
Boolean;
Q String toString ( ) - String
.

2.1.3. Byte
- , Byte.

Q Byte (byte value) - Byte.

CJ byte byte Value ( ) - Byte;


boolean equals (Object obj ) -
Byte;
Q int
hashCode ( ) - (-)
Byte;
'Q s t a t i c byte parseByte (String s ) -
String;
static byte parseByte (String s, int radix) - String ;
String toString ( ) - String, Byte.

s t a t i c byte MAX_VALUE - ;
Q static byte MIN_VALUE - .

2.1.4. Character

- - Char.

Character (char value) - Character.

Q char charValue () - Character;


Q s t a t i c int digit (char, ch, int radix) -
;
Q boolean equals (Object o b j ) - ;
Q int hashCode () - (-)
Character;
Q static boolean isDigit(char ch)-,
ch ;
Q static boolean isLowerCase (char ch) - ,
; static boolean isUpperCase (char ch) - ,
;

-
cdsetupl.0.0.76 - ;
Q Sony Ericsson -
Sony Ericsson:
semcJ2me_sdk_2_l_0_beta - Sony Ericsson J2ME SDK 2.1;
semc_SDK21_patch - Sony Ericsson J2ME SDK 2.1;
Packagel_1.5.9.2 - ;
Q Motorola -
Motorola:
sdk41ga - Motorola Lanchpad for J2ME;
' G Samsung -
Samsung:
JSDKvlJ) - SamsungJSDK 1.0.

3. -
- :
SDK - :
ffj_me_win32 - Sun One 4 Mobile Edition;
j2me_wireless_toolkit-2_l-windows J2ME
Wireless Toolkit 2.1;
J2re-l_4_l_02-windows-i586 -Java Runtime;
j2sdk-l_4_2_03-windows--i586-p -Java SDK SE;'
Q Code - ;
Q' Nokia - Nokia:
Linux Linux;
nds_jme_linux_v2_0.tar - Nokia Developer's Suite 2.0 for Linux;
nS30_jme_concept_sdk_linux_bO_2.tar ;
nds_jme_v_2_J) - Nokia Developer's Suite 2.0 for J2ME;
Nokia_S40_DP20_SDK_bet_0[l].5.0 - ;
nS40_jme_concept_sdk_bO_3 - ;
nS60_jme_sdk_v2_l - ;
nS90_jme_sdk_vl_0_b - ;
Nokia_5100_SDK_Final_l_0 - 5100;
n3410_sdk_vl_0 3410;
Nokia_PC_Suite_51_ru - ;
Q Siemens -
Siemens:
smtk_0_13_2_59 - Siemens Mobility Toolkit for Java Development;
2128_0_12_15_1 - 2128;
c55_0_12_15_l - 55;
_0_12_24 - ;
m50_Chinese_setup - 50 ;
m50_setup - 50;
55_0_12_09_1 - 55;
55_0_12_09_1 55;
mc60_setup - ;
s55_0_12_l 1_1 - s55;
s57_0_12_09_l - s57;
sl45_Chinese_setup - sl45 ;
sl45_setup - s!45;
s!55_0_12_05 - s!55;

Java 2 Micro Edition

2.11.5. RecordStore
.

Q int addRecord(byte[] data, int o f f s e t , int numBytes) ;


G void addRecordListener(RecordListener listener) ;
Q void closeRecordStore ( ) ;
void deleteRecord(int recordld) - ;
Q static void deleteRecordStore(String recordStoreName) ;
Q long getLastModified() -
;
Q String getNameO - ;
Q int getNextRecordlDQ - ;
Q int getNumRecords ( ) - ;
Q byte[] getRecord(int recordld) - ;
int getRecord(int, recordld, byte[] b u f f e r , int o f f s e t ) ;
Q int getRecordSize(int recordld) - ;
Q int get Size () - ;
Q int getSizeAvailable() -
;
Q int getVersionO - ;
Q static String [] listRecprdStores()'- ;
G static RecordStore openRecordStore(String recordStoreName, boolean createlfNecessary) - ;
Q static RecordStore openRecordStore(String recordStoreName, boolean createlfNecessary, int authmode, boolean writable) - ;
Q.static RecordStore openRecordStore(String recordStoreName, String vendorName, String suiteName)
;
Q void removeRecordListener(RecordListener listener) - ;
Q void setMode(int authmode, boolean writable) - ;
Q void setRecordfint recordld, byte[] newData, int o f f s e t ,
int numBytes) .

Q static int AUTHMODE_ANY - ;


Q static int AUTHMODE_PRI VATE - .

javax.microedition.rms
Q static int FOLLOWS - ;
static int PRECEDES - .

2.11.2. RecordEnumeration
.

Q void destroy () - ;
Q boolean hasNextElement () - true, ;
Q boolean hasPreviousElement ( ) - true,
;
boolean isKeptUpdated ( ) - true ,
;
Q void keepupdated(boolean keepUpdated) - , , ;
Q byte [ ] nextRecord ( ) - ;
Q int nextRecordld ( ) -
;
G int numRecords ( ) - ;
byte[]< previousRecord() -
;
Q int previousRecordld ( ) -
;
Q void rebui Id ( ) - ;
Q void reset () - .

2.11.3. Record Filter


.

boolean matches (byte [] candidate) - true,


.

2.11.4. RecordListener
, .

Q void reqordAdded(RecordStore recordStore, int recordld) ;


void recordChanged(RecordStore recordStore, int recordld) - ;
Q void recordDeleted(RecordStore recordStore, int recordld) - .

Java 2 Micro Edition


Q void resumeRequest ( ) - ;
Q protected abstract void startAppO - ;
.

2.9.2.
Q MlDletStateChangeException -
MIDlet.

2.10. javax.microedition.pki
.

2.10.1. Certificate

String getlssuerO - ;
Q long getNotAfter ( ) - ;
1 getNotBef ore ()- , ;
Q String getSerialNumber () - ;
Q String getSigAlgName () -
;
Q String getSubj ect ( ) - ;
G String getType ( ) , - ;
String getVersion() - .

2.10.2.
Q Certif icateExceptio - , .

2.11. javax.microedition.rms
, ,
.

2.11.1. RecordComparator
.

Q int compare (by te[] reel, byte [] rec2) - .

Q static int EQUIVALENT - ;

jovax.microedition.midlet

Q static byte BLOCK_END - ; .


Q static byte BLOCK_START - ;
Q static byte C4 - ;
Q static byte PLAY_BLOCK - ;
Q static byte REPEAT - ;
Q static byte RESOLUTION - ;
Q static byte SET_VOLUME - ;
Q static byte SILENCE - ;
Q static byte TEMPO - ;
Q s t a t i c byte VERSION - .

2.8.2. VolumeControl
.

Q int getLevelt) - ;
Q boolean isMuted() - ;
Q int setLeveKint level) - . 0 100;
Q void setMute (boolean mute) - . .

2.9. javax. microedition. midlet



(MIDP).

2.9.1. MIDIet
MIDIet
.

Q protected MIDIet () - .

Q int checkPermission (String permission) - ;


protected abstract void destroyApp(boolean unconditional) - ;
Q String getAppProperty (String key) ;
Q void notifyDestroyed ( )
;
Q void n o t i f y Paused ( )
;
Q protected abstract void pauseAppO - ;
Q boolean platformRequest (String URL) -
URL;

Java 2 Micro Edition

Q static String CLOSED - ;


Q static String DEVICE_AVAI.LABLE - ;
'static String DEVICE_UNAVAILABLE-
;
static String DURATION_UPDATED - ;
Q static String END_OF_MEDIA - 0
;
static String ERROR - ;
Q static String STARTED - ;
Q static String STOPPED - ;
static String VOLUME_CHANGED -
.

2.7.5. Manager
.

Q static Player createPlayer(InputStream stream, String type ) - ;


static Player createPlayer(String locator) - ;
Q static
StringUgetSupportedContentTypes(String protocol) - ;
static String[] getSupportedProtocols(String conteht_ty. ) ;
Q static void playTone(int note, int duration, int volume)
.

Q static String TONE_DEV I E_LOCATOR- .

<

2.7.6.

..,;>.- ' ' " '

MediaException - .

2.8. javax.microedition.media.control
.

2.8.1. ToneControl
.

void setSequence (byte [] sequence) -


.

javax.microedition.media

P Control getControl (String controlType) - , ;


Control [ ] getControls ( ) - .

2.7.3. Player
.

void addPlayerListener(PlayerListener playerListener) ;


void close ( ) - ;
void deallocate ( ) - , ;
String getContentType ()- , ;
long getDuration() - ;
long getMediaTime ( ) - ;
int getStateO - ;
void prefetch ( ) - ;
void realize ()- ;
void
removePlayerListener(PlayerListener
playerListener ) - ;
void setLoopCount (int count) - ;
long setMediaTime (long now) - ;
void start () - ;
void s t o p ( ) .

static int CLOSED - ;


static int PREFETCHED - ;
s t a t i c int REALIZED- ;
s t a t i c int STARTED ;
static long TIME_UNKNOWN - ;
static int UNREALIZED - .

2.7.4. PlayerListener
.

void playerUpdate(Player player, String event,


eventData) - .

Object

Java 2 Micro Edition


Q static int TRANS_ROT180 - 180;
Q static int TRANS_ROT270 - 270;
Q static int TRANS_ROT90 - 90.

2.6.5. Tiled Layer


.

Q TiledLayer(int columns, int rows, Image image, int


tileWidth, int tileHeight) - , , .

Q int createAnimatedTile(int staticTilelndex) - ;


void f i l l C e l l s ( i n t col, int row, int numCols, int
numRows , int tilelndex) - ;
Q int getAnimatedTile (int animatedTilelndex) -
;
Q int getCell(int col, int row) - ;
Q int getCellHeight ( ) - ;
Q int getCellWidth () - ;
int getColumns ( ) - ,
;
Q int getRows ( ) - , ;
G void paint (Graphics g) -;
void setAnimatedTile(int animatedTilelndex, int staticTilelndex) - ;
Q void setCell(int col, int row, int tilelndex) - ;
Q void setStaticTileSet(Image image, int tileWidth, int
t i 1 eHe i ght) - .

2.7. javax.microedition.media
MIDP 2.0 4 .

2.7.1. Control
.

2.7.2. Controllable
.

javax.microedition.lcdui.game
2.6.4. Sprite
, .

G Sprite (Image image) - ;


Q Sprite(Image image, int frameWidth, int frameHeight) ;
Q Sprite (Sprite s)- .

G boolean collidesWithfSprite s, boolean pixelLevel) - ;


Q boolean collidesWith(TiledLayer t, boolean pixelLevel)

TiledLayer;
Q public void def ineRef erencePixel (int x, int )
, ;
Q int getFrameO - ;
Q int getFrameSeguenceLength () -
;
Q int getRawFrameCount ( ) -
;
Q int getRef P i x e l X t ) - X ;
Q int getRef PixelY ( ) Y ;
Q void next Frame ( ) - ;
Q void paint (Graphics g) - ;
Q void prevFrame ( ) - ;
Q void setFrame(int sequencelndex) - ;
Q void setFrameSequence (int [] sequence) - ;
void setlmage(Image img, int frameWidth, int frameHeight ) - ;
void setRefPixelPosition(int x, int ) - X Y ;
Q void setTrans form (int transform)'-
.

Q static int TRANS_MIRROR - ;


Q s t a t i c int TRANS_MIRROR_ROT180 -
180 ;
Q static int TRANS_MIRROR_ROT270 -
270 ;
Q s t a t i c int TRANS_MIRROR_ROT90-
90 ;
static int TRANS_NONE - ;

\
Java 2 Micro Edition

static int
G static int
G static int
Q static int
Q static int
Q static int
Q static, int
static int
static int

DOWN_PRESSED - ;
FIRE_PRE.SSED - ;
GAME_A_PRESSED - ;
GAME_B_PRESSED - ;
GAME_C_PRESSED - ;
GAME_D_PRESSED - D;
LEFT_PRESSED - ;
RIGHT_PRESSED - ;
UP_PRESSED - .

2.6.2. Layer
,

Q int getHeight ( ) - ;
Q int getwidth ( ) - ;
int g e t x ( ) ;
Q int getY ()- ;
boolean i s V i s i b l e ( ) . ;
void move (int dx, int dy) - dx dy ;
Q abstract void paint (Graphics g) - ;
Q void setPosition(int x, int ) - , ;
Q void setVisible (boolean visible) -
.

2.6.3. LayerManager
.

Q LayerManager ( ) - .

Q void append (Layer 1) - ;


Layer getLayerAt (int index) - ;
Q int getSizeO - ;
Q void insert (Layer 1, int index) -
;
Q void paint (Graphics g, int x, int ) -
;
Q void remove (Layer 1) - ;
Q void setViewWindow(int x, int , int width, int height) .

jovax.microedition.lcdui.game
Q static int INITIAL_CAPS_WORD - .
;
Q s t a t i c int NON_PREDICTIVE - , , ;
U static int NUMERIC - ;
Q static int PASSWORD - ;
Q static int PHONENUMBER - ;
D static int UNEDITABLE - ; ,
Q s t a t i c int URL - .

2.5.27. Ticker
.

Q Ticker (String str) - .

String getstringt) - ,
Ticker;
void setstring (String str) Ticker, .

2.6. javax.microedition.lcdui.game
,
.

2.6.1. GameCanvas
, .

protected GameCanvas (boolean suppressKeyEvents) - GameCanvas.

G void flushGraphics ( ) ;
Q void flushGraphics(int x, int y, int width, int height).
;
protected Graphics getGraphics ( ) - GameCanvas;
int getKeyStates ( ) - , ;
Q void paint (Graphics g) - , GameCanvas.

Java 2 Micro Edition

2.5.26. TextField
,
Form.

TextField (String label, String t e x t , int maxSize, int


constraints) ,
, , Form.
void delete (int o f f s e t , int length) -
;
int getCaretPosition( ) -
;
int getChars (char [] data) -
TextField- ;
Q int getConstraints ( ) - ;
Q int getMaxSize ( ) - , TextField;
Q String g e t S t r i n g O - TextField;
void insert (char [] data, int o f f s e t , int length, int
position) - TextField;
Q void insert (String src, int position) -
TextField;
Q void -setChars (char [] data, int o f f s e t , int length) - TextField ;
void setConstraints (int constraints) - ;
Q void setlnitiallnputMode (String characterSubset) -
;
Q int setMaxSize ( int maxSize) - TextField;
G void setString (String text) - TextField
;
Q int size ( ) - TextField.

Q static int ANY - ;


Q s t a t i c int CONSTRAINT_MASK - ;
Q static int DECIMAL ;
Q s t a t i c int EMAILADDR - ;
static int INITIAL_CAPS_SENTENCE -
;

javax.microedition.lcdui

JliBBHIHEIQ

int getAppearanceMode ( ) - ;
Q Font g e t F d n t ( ) - ;
String getTextO - String I tern;
Q void setFont(Font f o n t ) - ;
G void s e t P r e f e r r e d S i z e ( i n t width, int .height) ;
Q void
setText (String
t e x t ) -
Stringltem.

2.5.25. TextBox
.

Q TextBox(String t i t l e , String text, int maxSize, int


constraints) - ,
, .

void delete (int o f f s e t , int length) -


;
Q int getCaretPosition() -
;
Q int getChars (char [ ] data) -
TextBox ;
int getConstraints ( ) ;
Q int getMaxSize ()- , TextBox;
Q String getStringO - TextBox;
Q void i n s e r t ( c h a r [ ] data, int o f f s e t , int . l e n g t h , int
position) - TextBox;
Q void insert (String src, int position) -
TextBox;
Q void setChars(char[] data, int o f f s e t , int l e n g t h ) - TextBox ; .
G void setConstraints (int constraints) ;
devoid s e t l n i t i a l l n p u t M o d e ( S t r i n g characterSubset) -
;
Q int setMaxSize (int m a x S i z e ) - TextBox;
Q void setString( String text) - TextBox ;
Q.void setTicker (Ticker ticker) - ;
Q void setTitle (String s) - ;
Q int s i z e ( ) - TextBox.

Java 2 Micro Edition


void s e t F i t P o l i c y ( i n t f i t P o l i c y ) - ;
Q void setFont(int elementNum, Font font) -
;
d void setSelectCommand (Command command) - IMPLICIT;
Q void setSelectedFlags(boolean[] selectedArray)- ;
G void setSelectedlndex(int elementNum, boolean selected) ;
Q void setTicker (Ticker ticker) - ;
Q void setTitle (String s) - ;
Q int size ( ) - .

Q static Command SELECT_COMMAND -


IMPLICIT.

2.5.22. Screen
.

2.5.23. Spacer
.

Spacer (int minWidth, int minHeight) -


.

Q void addCommand(Command cmd) - ;


Q. void setDefaultCommand(Command cmd) -
;
Q void setLabel (String label) - ;
Q'void setMinimumSize(int minWidth, int minHeight) - .

2.5.24. Stringltem
.

Q Stringltem (String label, String text) -


;
Q Stringltem(String label, String text, int appearanceMode) - .

javax.microedition.lcdui
Q
Q
Q
13

Q
Q

static in.t LAYOUT_NEWLINE_AFTER - ;


static int LAYOUT_NEWLINE_BEFORE - ;
static int LAYOUT_RIGHT - ;
static int LAYOUT_SHRINK - ;
static int LAYOUT_TOP - ;
static int LAYOUT_VCENTER - ;
static int LAYOUT_VEXPAND -
;
static int LAYOUT_VSHRINK -
;
Q static int PLAIN -
.

2.5.21. List
.

Q List (String title, int listType) - ;


List(String t i t l e , int listType, S t r i n g [ ] v s t r i n g E l e m e n t s ,
Image [ ] imageElements) - , , .

int append(String stringPart, Image imagePart)-


;
CD void delete (int elementNum) - ;
Q void deleteAllO - ;
Q int getFitPolicyO - ;
Q Font getFont(int elementNum) -
;
Q Image getlmage(int elementNum) - ;
int getSelectedFlags(boolean[] selectedArray_return) ;
Q int getSelectedlndex() -
;
Q String getString (int elementNum)
;
Q void insert(int elementNum, String stringPart, Image imagePart ) - .
U boolean isSelectedfint elementNum) - ;
Q void removeCommand (Command cmd) - ;
Q void s e t ( i n t elementNum, String stringPart, Image imagePart ) ;

Java 2 Micro Edition

Q String get Al tText ()'- ;


Q int get AppearanceMbde ( ) - ;
Q Image getlmage ( ) - ;
Q int getLayout ( ) -
void set AltText (String text) ;
void setlmage(Image img) - ;
Q void setLayout(int layout) - .

2.5.20. Item
,
Form.

Q void addCommand(Command cmd) - ;


String getLabel ( ) - Item;
Q int getLayout ( ) - ;
int getMinimumHeight ( ) - ;
Q int getMinimumWidth() - ;
Q int getPreferredHeight ( ) - ;
Q int getPref erredWidth ( ) - ;
Q void notifyStateChanged() - , .
ItemStateListener ;
Q void removeCommand (Command cmd) - .
Q void setDefaultCommand (Command cmd) -
;
Q void setltemCommandListener (ItemCommandListene-r 1) - ;
void setLabel (String label) -
;
Q void setLayout (int layout) -
;
Q void setPref erredSize (int width, int height) -
.

Q static int
Q static int
Q static int
Q static int
Q static int
Q static int
Q static int
Q static int

BUTTON - ;
HYPERLINK - ;
LAYOUT_2 - ;
LAYOUT_BOTTOM - ;
LAYOUT_CENTER - ;
LAYOUT_DEFAULT - ;
LAYOUT_EXPAND - ;
LAYOUT_LEFT - ;

javax.microedition.lcdui
Q static int TOP - ;
Q static int VCENTER - .

2.5.18. Image

PNG.

s t a t i c Image createlmage(byte[] imageData, int imageO f f s e t , int imageLength) - , ;


s t a t i c Image createlmage (Image source) - ;
Q static Image createlmage(Image image, int x, int y , int
width, int height, int transform) -
, ;
Q static Image createlmage (InputStream stream) -
;
static Image createlmage(int width, int height) -
;'
Q static Image createlmage (String name) -
;
Q static Image createRGBImage(int[] rgb, int width, int
height, boolean processAlpha) - , ARGB;
Q Graphics getGraphics() ;
int getHeightO - ;
Q void g e t R G B ( i n t [ ] rgbData, int o f f s e t , int .scanlength,
int x, int y , int width, int height) - ARGB ;
int getWidth ( ) - ;
boolean isMutable ( ) ' - .

2.5.19. Imageltem

Q Imageltem(String label, Image img, int layout, String


altText) Imageltem , , ;
Q Imageltem(String label, Image image, int layout, String
altText, int appearanceMode) - Imageltem
, , , , .

Java 2 Micro Edition


void fillRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight) - 1
, ;
void f illTriangle (int xl, int y l , int x2 , int y2 , int. x3 ,
int y3 ) - ;
int getBlueComponent ( ) - ;
int getClipHeight ( ) - ;
Q int getClipWidtht) - ;
int getClipX()- X
;
Q int getClipY ( ) - Y
;
Q int getColor () - ;
int getDisplayColor (int color) - ;
Q Font getFontO - ;
Q int getGrayScale ( ) - ;
Q int getGreenComponent ().- ;
Q int getRedComponent ( ) - ;
Q int getStrokeStyle () ;
Q int getTranslateX() - X / ;
Q int getTranslateY()- Y ;
Q void setClip(int x, int y, int width, int height) ;
Q void setColor(int RGB) -
RGB;
Q void setColor(int red, int green, int blue) -
red, green blue;
Q void setFont (Font font) - ;
Q void setGrayScale (int value) - ;
Q void setStrokeStyle (int style) - , SOLID DOTTED;
Q void translate (int x, int ) -
(, ).

Q static int BASELINE - ;


Q static int BOTTOM - ;
Q static int DOTTED - ;
Q static int HCENTER - ;
Q static int LEFT - ;
Q static int RIGHT - ;'
Q static int SOLID - ;

javax.microedition.lcdui
Q static int INDEFINITE -
.

2.5.17. Graphics

.

Q void clipRect (int x, int y, int width, int height) - ;


. void copyAreafint x_src, int y_src, int w i d t h , int
height, int x_dest, int y_dest, int anchor) - x_src,
y_src, width, height, x_dest, y_dest;
Q void drawArc(int x, int y, int width, int height, int
startAngle, int arcAngle) - ;
Q void drawChar(char character, int x, int y, int anchor) ;
Q void drawChars(char[] data, int o f f s e t , int length, int
x, int y, int anchor) - ;
Q void drawlmage (Image img, int x, int y , int anchor) ;
Q void drawLine(int x l , int y l , int x2 , int y 2 )
xl yl 2 2;
] void drawRegion (Image src, int x_src, int y_src, int
width, int height, int transform, int x_dest, int y_dest,
int anchor) - ;
.Q void drawRGB(int[] rgbData, int o f f s e t , int scanlength,
int x, int y, int width, int height, boolean processAlpha) ARGB
;
Q void drawRoundRect(int x, int , ' int width, int height,
int arcWidth, int a r c H e i g h t ) - ,
;
Q void "drawstring (String str, int x, int y, int anchor) ;
void drawSubstring(String str, int o f f s e t , int len, int
x, int y, int anchor) -
;
Q void f i l l A r c ( i n t x, int y, int width, int height, int
startAngle, int arcAngle) - ;
Q void f i l l R e c t ( i n t x, int y, int width, int height) -
;

Java 2 Micro Edition


Q void set(int itemNun), Item item) - ,
itemNum, ;
Q void setltemStateListener (ItemStateListener iListener) iListener , iListener;
int size () - .

2.5.16. Gauge
, .

Q. Gauge(String label, boolean interactive, int maxValue,


int initialValue) -
, .

.
.'
Q void addCommand (Command cmd) ;
Q int getMaxValue ()- ;
int getValue ()- ;
boolean islnteractive ( ) ;
Q void setDefaultCommand (Command cmd) - Item;
Q void setltemCommandListener(ItemCommandListener 1)- ;
Q void setLabel (.String label) - ;
Q void setLayout (int layout) - ;
Q void setMaxValue (int maxValue) -
;
Q void setPreferredSize(int width, int height) - ;
void setValue(int value) - .

Q static int CONTINUOUS_IDLE -


;
Q static int CONTINUOUS_RUNNING -
;
Q static int INCREMENTAL_IDLE - ;
Q static int INCREMENTAL_UPDATING -
;

javax.microedition.lcdui
Q boolean isPlainO - true,
1
Plain; '
Q boolean isUnderlined() - true, Underlined;
Q int stringWidth (String str) - ;
Q int substringWidthfString str, int o f f s e t , int len) - .

Q s t a t i c int FACE_MONOSPACE - ;
Q s t a t i c int FACE_PROPORTIONAL - ;
s t a t i c int FACE_SYSTEM - ;
Q static int FONT_INPUT_TEXT - ;
G static int FONT_STATIC_TEXT - ;
Q static int SI ZE_LARGE- ;
Q static int SIZE_MEDIUM - ; ,
Q static int SIZE_SMALL - ;
Q static, int STYLE_BOLD - ;
static int STYLE_ITALIC - ;
Q static int STYLE_PLAIN - ;
Q static int STYLE_UNDERLINED - .

2.5.15. Form
, .

Q Form (String t i t l e ) - ;
Form (String t i t l e , Item[] items) - 11 em.

G int append (Image img) ;


Q int append (Item item) -
Item ;
Q int append (String str) - ;
Q void delete (int itemNum) -
itemNum;
G void deleteAll () - ;
G Item get (int itemNum) - ;
Q int getHeight ( ) -
;
G int getWidth () -
;
Q void insert (int itemNum, Item item) -
;

Java 2 Micro Edition

2.5.13. Displayable
, .

G void addCoiranand (Command cmd) - ;


Q int getHeight ( ) - ;
Q Ticker getTicker ( ) - ;
Q String getTitleO - ;
Q int getWidth() - ;
Q boolean is Shown - ;
Q void removeCommand (Command cmd) - ;
Q void setCommandListener(CommandListener 1)
;
Q-void setTicker (Ticker ticker) - ;
. Q void setTitle (String s) - ;
Q protected void sizeChanged(int w, int h) -
.

2.5.14. Font
.

~Q int charsWidth(char[] ch, int o f f s e t , int length)-


;
Q int charWidth(char ch) - ;
Q int getBaselinePosition() -
;
Q static Font getDefaultFont ( ) - , ;
Q int getFace ( ) ;
Q static Font getFont(int fontSpecif ier) -
Customltem ;
Q static Font getFont(int f a c e , int style, int s i z e ) - , ;
Q int getHeight ( ) - ;
Q int getSize ()- ;
Q int getStyleO - ;
Q boolean isBoldO - true,
Bold;
Q boolean i s l t a l i c ( ) - true,
italic;

javax.microedition.lcdui

' void callSerially (Runnable r) - run ( ) Runnable;


boolean f lashBacklight (int duration) - ;
HI int getBestlmageHeight (int imageType) -
;
int getBest!mageWidth(int imageType) -
;
int getBorderStyle (boolean highlighted) -
;
Q int getColor(int colorSpecifier) - ;
Q Displayable getCurrent ( ) - Displayable ;
static Display getDisplay (MIDlet m) -
Display ;
Q boolean isColor ( ) ;
int
numAlphaLevels() - -
;
int numColors (.) - ;
Q void setCurrent(Alert alert, Displayable 'nextDisplayable) - Alert;
G void setCurrent(Displayable nextDisplayable) , Displayable;
Q void setCurrentltem(Item item) -
Item;
Q boolean vibrate (int duration) - .

Q s t a t i c int ALERT- ;
Q static int CHOICE_GROUP_ELEMENT -
ChoiceGroup;
Q static int -COLOR_BACKG-ROUND ,
getColor ( ) ;
Q static int COLOR_BORDER - , getColor() ;
Q static int COLOR_FOREGROUND - ,
getColor ( ) ;
Q static int COLOR_HIGHLIGHTED_BACKGROUND - , getColor ( ) ;
Q static int COLOR_HIGHLIGHTED_BORDER - , getColor ( ) ;
Q static int COLOR_HIGHLIGHTED_FOREGROUND - , getColor ( ) ;
! s t a t i c int LIST_ELEMENT - List.

Java 2 Micro Edition


Q protected void repaint () - ;
Q protected void repaint (int x, int y, int w, int h) ;
Q protected void showNotifyO - ;
Q protected void sizeChanged(int w, int h)-- .

Q protected static int KEY_PRESS - ;


Q protected static int KEY_RELEASE - ;
Q protected static int KEY_REPEAT - ;
Q protected static int NONE - ;
Q protected static int POINTER_DRAG - ;
Q protected static int POINTER_PRESS -;
Q protected static int POINTER_RELEASE - ;
Q protected static int TRAVERSE_HORIZONTAL -
;
protected static int TRAVERSE_VERTICAL - .

2.5.11. Date Field


, .
Form, Item.

Q DateField(String label, int mode) -


DateField, ;
Q DateField(String label, int mode, TimeZone timeZone)
DateField, , .

Q Date getDateO - ;
Q void setDate(Date date) - ;
Q int getlnputMode () - DATE,
TIME DATAJTIME;
Q void setlnputMode(int mode) - DATE,
TIME DATE_TIME.

Q static int DATE-;


Q static int DATE_TIME - ;
Q static int TIME - .

2.5.12. Display
,
.

jovax.microedition.lcdui
static int HELP - ;
static int ITEM - , ;
static int OK - ;
static int SCREEN - -;
P s t a t i c int STOP - .

2.5.10. Custom Item


Form.

protected Customltem( String label) - Customltem.

int getGameAction (int keyCode)-


;
protected int getlnteractionModes() -
;
protected abstract int getMinContentHeight() - ;
protected abstract int getMinContentWidth() - ;
protected abstract int getPrefContentHeight(int width) ;
protected.abstract int getPrefContentWidth(int height) ;
protected void hideNotify ( ) - ;
protected void invalidate () ;
protected void keyPressed(int key'Code)- ;
protected void keyReleased(int keyCode) - ;
protected void keyRepeatedfint keyCode) - ;
Q protected abstract void paint(Graphics g, int w, int h ) ;
P protected void pointerDragged(int x, int ) -
;
protected void pointerPressed(int x, int ) -
;
protected void point erReleased( int x, int ) - ;

Java 2 Micro Edition


int getSelectedlndex ( ) -
;
Q String g e t S t r i n g ( i n t elementNum) -
;
. Q void
insert(int
elementNum,String
stringPart,Image
imagePart) - ;
Q boolean isSelected(int elementNum) - ;
Q void set(int
elementNum,
String . stringPart,
Image
imagePart). -
; ;
Q void setFitPolicy ( i n t f i t P o l i c y ) - ;
void setFont(int elementNum, Font font)
;
void setSelectedFlags (boolean[] selectedArray) ;
Q void setSelectedlndex(int elementNum, boolean selected)
;
Q int size ( ) - .

2.5.9. Command
,
, .

Q Command(String label, int commandType, int priority) . : ,


;
Q Command(String shortLabel, String longLabel, int commandType, int priority) - . : ,
.

int get CommandType ( ) - ;


Q String getLabel ( ) - ;
String getLongLabel ( ) - ;
Q int getPriority ()- .

Q static int BACK-;


Q static int CANCEL - ;
Q static int EXIT - ;

javax.microedition.lcdui
static
static
Q static
static
Q static
Q static
Q static
Q static
Q static
Q static
Q static
Q static
a static
Q static
Q static
Q static
static
Q static
Q, static

int GAME_A - ;
int GAME_B - ;
int GAME_C - ;
int GAME_D - D;
int KEY_NUMO - 0;
int KEY_NUM1- 1;
int KEY_NUM2 - 2;
int KEY_NUM3 - 3;
int KEY_NUM4 - 4;
int KEY_NUM5 - 5;
int KEY_NUM6 - 6;
int KEY_NUM7 - 7;
int KEY_NUM8 - 8;
int KEY_NUM9 - 9;
int KEY_POUND - #;
int KEY_STAR - *;
int LEFT - ;
int RIGHT - ;
int UP - .

2.5.8, ChoiceGroup
. Form,
Item Choice.

Q ChoiceGroup (String label, int choiceType) -


, ;
Q ChoiceGroup(String label, int choiceType, String[] stringElements, Image [] imageElements) - ,
, ,
.

Q int append (String stringPart, Image imagePart) -,


;
void delete (int elementNum) - ;
void deleteAlK) - ;
Q int getFitPolicy ( ) ;
Q Font getFont(int elementNum) -
;
Q Image getlmage(int elementNum) - ;
Q int getselectedFlags(boolean[]selectedArray_return) -:
Boolean ;

Java 2 Micro Edition

Q int getGameAction (int keyCode) -


;
Q int getKeyCode (int gameAction) -
;
Q String getKeyName (int keyCode) - ;
Q boolean hasPointerEvents ( ) -
;
G boolean hasPointerMotionEvents ( ) - ;
. .
Q boolean hasRepeatEvents () -
;
Q protected void hideNotifyO -
Canvas ;
boolean isDoubleBuf fered( ) - ;
Q protected void keyPressed(int keyCode) - ;
Q protected void keyReleased(int keyCode) - ;
>,
Q protected void keyRepeated( int keyCode) -
;
Q protected abstract void paint (Graphics g) -
;
protected void pointerDragged(int x, int )
;
Q protected void pointerPressed(int x, int ) -
,
;
Q. protected void pointerReleasedf int x, int ) -
;
Q void repaint () - ;
G void repaint (int x, int , int width, int height) ;
Q void serviceRepaints ( ) - ;
\
void setFullScreenMode (boolean mode) - ;
Q protected void showNotifyO -
Canvas ;
Q protected void sizeChanged(int w, 'int h) - .

Q static int DOWN - ;


Q static int FIRE -
;

javax.microedition.lcdui

Q int getDef aultTimeout ( ) - ;


Q Image get Image () - , Alert;
Q Gauge getlndicator ( ) - Gauge;
01 String getStringO - ; ,
Q int getTimeout ( ) - ;
Q AlertType getTypeO - ;
Q void removeCommand (Command cmd) - ;
Q void setCommandListener (CommandListener 1) -
;!
Q void set Image (Image i m g ) - ;
Q void setlndicator (Gauge indicator) -
Gauge;
Q void setstring (String str) ;
Q void setTimeout (int time) - ;
Q void setType (AlertType type) -
.

U static Command DISMISS_CQMMAND - ;


Q static int FOREVER - .

2.5.6. AlertType
.

Q protected AlertType () - .

Q boolean playSound( Display display) - .

Q static AlertType ALARM - ;


Q static AlertType CONFIRMATION - ;
Q static AlertType ERROR - ;
Q static AlertType INFO - ;
Q static AlertType WARNING - .

2.5.7. Canvas
,
.

Q protected Canvas () - Canvas.

Java 2 Micro Edition


Q int size ( ) - .

Q static int EXCLUSIVE - ;


Q static int IMPLICIT - ;
Q static int MULTIPLE ;
static int POPUP - ;
static int TEXT_WRAP_DEFAULT -
;
Q static int TEXT_WRAP_OFF - ;
Q static int TEXT_WRAP_ON - .

2.5.2. CommandListener
.

Q void commandAction(Command , Displayable d) -


.

2.5.3. ItemCommandListener
Item.

void commandAction (Command , Item item) - .

2.5.4. ItemStateListener
Item
Form.

Q void itemStateChangeddtem item) - Item.

2.5.5. Alert
.
.
,

Q Alert (String t i t l e ) - ;
Q Alert(String title, String alertText, Image alertlmage,
AlertType alertType) - , ,
.

void addCommand( Command cmd) - ;

javax.microeditibn.lcdui

2.4.19.
ConnectionNotFoundException - .

2.5. javax.microedition.lcdui
(UI) ,
, , .

2.5.1. Choice

Q int append(String s t r i n g P a r t , Image imagePart) -


;
Q void delete (int elementNum) - ;
-void deleteAll ( ) - ;
Q int getFitPolicy ( ) - ;
Q Font g e t F o n t f i n t elementNum) - ;
Q Image getlmage (int elementNum) - ;
int getSelectedFlags(boolean[]
selectedArray_return) ;
Q int getSelectedlndex ( ) - * ;
Q String getString (int elementNum) - ;
void insert (int elementNum-, String stringPart, Image
imagePart) - ;
Q boolean i s S e l e c t e d f i n t elementNum) - , ;
G void s e t ( i n t elementNum, String s t r i n g P a r t , Image imagePart ) - , ;
Q void setFitPolicy (int fitPolicy) - ;
Q void s e t F o n t ( i n t elementNum, Font f o n t ) -
;
Q void setSelectedFlags (boolean:'[] selectedArray) - ;
Q void setSelectedlndex (int; elementNum, boolean selected) ;

Java 2 Micro Edition


int getLocalPort ( ) - , .

2.4. 77, Connector


.

static Connection open (String name ) - ;


G static Connection open(String name, int mode) -
;
Q static Connection open ('String name, int mode, boolean
t imeout s ) - , . ;
G s t a t i c DatalnputStream openData!nputStream.( String name) ;
Q static
DataOutputStream
openDataOutputStream (String
name ) - ;
Q stati-c InputStream open!nputStream( String name) -
;
static OutputStream openOutputStream( String name) -
.

Q static int READ - ;


Q static int READ_WRITE - 4 ;
Q static int WRITE - ;

2.4. 18. PushRegistry


.

Q static String getFilter (String connection) - ;


Q static String getMIDlet (String connection) - (MIDlet) ;
Q static String [] listCbnnections (boolean available) - (MIDlet
suite);
Q static long registerAlarm( String midlet, long time) - ;
Q static void registerConnection (String connection, String
midlet, String f i l t e r ) -
;
G static boolean unregisterConnection (String connection) .

javax.microedition.io
Q Certificate getServerCertif icate ( ) - .

2.4.12. ServerSocketConnection
.

String
getLocalAddress () -
(socket);
Q int getLocalPort () - .

2.4.13. SocketConnection
(socket) .

1
String get Address () - ;
Q String getLocalAddress () - ;
int getLocal Port ( ) - ;
Q int get Port ( ) - ;
Q int getSocketOption (byte option) - ;
void setSocketOption(byte option, int value)
.

Q static byte DELAY - (0);


Q static byte KEEPALIVE - (2);
Q static byte LINGER (1);
Q static byte RCVBUF - (3);
Q static byte SNDBUF - (4).

2.4.14. StreamConnection
.

2.4.15. StreamConnectionNotifier
.

StreamConnection acceptAndOpen ( ) - ,
.

2.4.16. UDPDatagramConnection
.

String getLocalAddress ()- ;

Java 2 Micro Edition


Q static int HTTP_GONE - ;
Q static int HTTP_INTERNAL_ERROR - ;
Q static int H1TP_LENGTH_REQUIRED - .

2.4.7. HttpsConnection
.

,
Q int get Port ( ) - ;
Q' Securitylnfo getSecur,ity!nfo() - .

2.4.8. InputConnection
.

DatalnputStream openData!nputStream() - ;
Q inputStream openlnputstreamf)-
.

2.4.9. OutputConnection
;

Q DataOutputStream openDataOutputStream() - ;
Q OutputStream openOutputStream() - .

2.4.10. SecureConnection
.

Q Securitylnfo getSecurity Info ( ) - . .

2.4.11. Securitylnfo
.

String
getCipherSuite() -
;
Q String getProtocolName ( ) -
;
Q String getProtocolVersiont.) -
;

javax.microedition.io
String getHeaderField (String name) - ;
' l o n g getHeaderFieldDate (String name, long d e f ) -
;
Q int getHeaderFieldlnt (String name, int def)-
; .
Q String getHeaderFieldKey (int n) -
;
Q String getHost ( ) - ;
Q long getLastModif i e d ( ) -
;
Q int get Port ( ) ' - ;
Q String getProtocol ( ) ;
Q String get-Query - ;
Q -String getRequestMethod() - ;
Q String getReguestProperty (String key) -
;
Q int getResponseCode ( ) HTTP;
String getResponseMessage ( ) - HTTP;
Q String getURLO - ;
Q void setRequestMethod (String method) - ;
Q void setRequestProperty(String key, String value) - .

Q static String GET - HTTP;


Q static String HEAD-
HTTP;
Q static int HTTP_ACCEPTED - , ;
Q stat ic int HTTP_BAD_GATEWAY - ;
Q static int HTTP_BAD_METHOD - ;
Q static int HTTP_BAD_REQUEST - ;
Q static int HTTP_CLIENT_TIMEOUT -
;
Q static int HTTP_CONFLICT - - ;
Q static int HTTP_CREATED - ';
Q static int HTTP_ENTITY_TOO_LARGE- -
;
static int HTTP_EXPECT_FAILED - ;
Q stat ic int HTTP_FORBIDDEN - , ;
Q static int HTTP_GATEWAY_TIMEOUT - ;

Java 2 Micro Edition

2.4.4. Datagram
.

Q String g&tAddress () - ;
Q byte [ ] getData ( ) - ;
int getLength ( ) - ;
Q int getOff set () ;
Q void reset () -
;
Q void .setAddress (Datagram reference) - , ;
void setAddress (String addr) - ;
Q void setData (byte [] b u f f e r , int o f f s e t , int len) - ;
void setLength(int len) - .

2.4.5. DatagramConnection
.

Q int getMaximumLength () ;
Q int getNominalLength() - ;
Q Datagram newDatagram(byte [] b u f , int size) -
;
Datagram newDatagram(byte[] b u f , int size. String addr) -;
Q Datagram newDatagram(int size) - ;
Q Datagram newDatagram(int s i z e , String addr) -
; Q void receive (Datagram dgram) - ;
void send (Datagram dgram) - .

2.4.6. HttpConnection
HTTP.

*Q long getDate () - ;
Q String getFi le ( ) - URL;
Q String getHeaderField(int n) -
;

javax.microedition.io
Q void write (int ) - ;
Q void write (String str) - ;
Q void w r i t e (String str, int o f f , int len) -
.

Q protected Object lock - .

2.3.14.
EDFException - ;
interruptedlOException -
-;
lOException - ;
Q UnsupportedEncodingException - ;
UTFDataFormatException - UTF-8.

2.4. javax.microedition.io
.

2.4.1. CommConnection
.

Q int getBaudRate -
;
int setBaudRate (int baudrate) -
.
.
\

2.4.2. Connection
.

void close ()- .

2.4.3. ContentConnection
.

Q String getEncoding ( ) - ;
Q long getLength()- ;
String getType () - .

Java 2 Micro Edition


void write (byte [] buf , int o f f , int len) -
len b
;
Q void write (int b) .

2.3.12. Reader
, .

Q protected Reader () - ;
Q protected Reader (Object lock) - ,
lock.

'
.
abstract void closet) - ;
void mark (int readAheadLimit) - ;
boolean markSupported ( ) -
;
Q int read ( ) - ;
Q int read ( c h a r t ] c b u f ) ;
Q abstract int r e a d ( c h a r t ] cbuf, int o f f , int len) - ;
Q boolean ready () - ;
void r e s e t ( ) - ;
Q long skip (long n) - .

Q protected Object lock - .


,

2.3.13. Writer
, .

Q protected W r i t e r ( ) -
;
G protected Writer (Object lock) -
, lock.

abstract void c l o s e t ) - ;
abstract void f l u s h O - ;
Q void write (chart] c b u f ) - ;
abstract void w r i t e ( c h a r t ] cbuf, int o f f , int len)- ;

java.io
Q void write (char[] c b u f , int o f f , int len) -
len b ;
Q void write (int ) - ;
Q void write (String str, int o f f , int len) -
len b ;

2.3.11. PrintStream
.

Q PrintStream (OutputStream out) - PrintStream, .

Q boolean checkError ( ) - ;
Q void close () - ;
Q void f l u s h ( ) - ;
Q void print (boolean b) - ;
Q void print (char ) - char;
Q void print (char [ ] s) - ;
void print (int i) - int;
void print (long 1) - long;
Q void print (Object obj ) - ;
Q void print (String s) - ;
void print In ( ) - ,
;
Q void println(booleaft x) ,
;
Q void println(char x) - char, ;
Q void println (char [] x) , ;
void println (int x) int, ;
void println (long x) long, ;
Q void println (Object x) - , ;
Q void println (String x) - , ;
Q protected void setError() - , true;

Java 2 Micro Edition


InputStreamReaider (InputStream is, String enc) -
InputStreamReader, ,
.

Q void lose () - ;
Q void m a r k ( i n t readAheadLimit) - ;
Q boolean markSupported() -
;
Q int read ( ) - ;
Q int read ( c h a r [ ] c b u f , int o f f , int len) -
;
Q boolean ready ()
;
void reset ( ) ;
Q long skip (long n) - .

2.3.9. OutputStream
, .

Q OutputStream ( ) - OutputStream.

Q void close () - - ;
Q void f l u s h () - ;
Q void write (byte [] b) - ;
Q void w r i t e ( b y t e [ ] b, int o f f , int len) -
len b
;
Q abstract
void write (int b) -
.

2.3.10. OutputStreamWriter
Writer,
.

Q OutputStreamWriter (OutputStream os) - OutputStreamWriter, ;


Q OutputStreamWriter(OutputStream os , String enc) -
'OutputStreamWriter, , .

void close () - ;
Q void f l u s h () - ;

java.io

Q void writeByte (int v) -


;
Q void writeChar (int v) - Hbix char ( - );
! void writeChars (String s) -
;
void w r i t e l n t ( i n t v) -
int ( );
void writeLong (long v) - long ( );
Q void writeShort (int v) - short ( );
void writeUTP (String str) -
.

protected OutputStream out - .

2. 3. 7. InputStream
, .

InputStream ( ) - InputStream.

Q int available ( ) -
;
void c l o s e t ) - ;
Q void mark(int readlimit) - ;
Q boolean markSupp'orted ( ) - ;
Q abstract read ( ) -
;
Q int read (byte [] b) -
;
Q int read (byte [] b, int o f f , int len) -
, len b ;
Q void resetO - ;
G long skip (long n) - .
-1

'

2. 3. 8. InputStreamReader
Reader,
.

InputStreamReader (InputStream
is) -
InputStreamReader, ;

Java 2 Micro Edition

Q boolean readBoolean() -
0, true,-
false;
Q byte readByteO - ;
Q char readChar () - ;
Q void readFully (byte [ ] b) - , ;
D void readFully (byte [] b, int. o f f , int len) -
len ;
Q int readlnt ( ) - int
( );
Q long readLongO -
long ( );
Q short readShort () -
short ( );
Q int readUnsignedShort ( ) - 0 256;
Q String readUTF ( ) - UTF-8;
Q Static String readUTF (Datalnput in) -
;
Q void reset () - ;
Q long skip (long n) - ;
Q int skipBytes (int n) - , .

Q protected InputStream in - .

2.3.6. DataOutputStream
DataOutput,
.

DataOutputStream(OutputStream out) -
.

Q void lose () - ;
Q void flushQ - ;
Q void write (byte [] b, int o f f , int len) -
len b
;
Q void write (int b) -
;
Q void writeBoolean (boolean v) - ;

java.io

2.3.4. ByteArrayOutputStream
.

Q ByteArrayOutputStream ( ) - ;
Q By teArrayOutput Stream (int s i z e ) -
.
\

Q void c l o s e ( ) - , ;
Q void reset () - ;
Q int size () - ;
U byte[] toByteArray() - ;
Q String toStringO -
;
void write (byte [] b, int o f f , int len) - , len b ;
U void write ( i n t b) - .

Q protected byte [] buf - ;


Q protected int count - .

2.3.5. DatalnputStream
Data Input,
.

Q DatalnputStream(InputStream in) -
.

Q int available ( ) -
;
Q void c l o s e ( ) - ;
Q void mark (int readlimit) ;
. boolean markSupportedt) - DatalnputStream ;
Q int read ( ) - ;
Q int read (byte [] b)-
;
Q int read (byte [] b, int o f f , int len) -
, 1 en b ;

Java 2 Micro Edition


Q void writelnt (int v) -
- int ( );
Q void writeLong( long v) - long ( );
void writeShort (int v) - short ( );
Q void writeUTF (String str) -
.

2.3,3. ByteArraylnputStream

.

Q ByteArraylnputStream (byte [ ]
b u f ) -
ByteArraylnputStream, buf ;
Q ByteArraylnputStream(byte[]
buf,
int
offset,
int
length) ByteArraylnputStream.
buf , o f f s e t
, length
.

Q int available () - 1
;
'
void close () - , ;
void mark (.int readAheadLimit) -
;
Q boolean markSupported() - ByteArraylnputStream ;
Q int read ( ) - ;
Q int read (byte [] b, int o f f , int len) -
, len b ;
Q void reset () - ;
Q long skip (long n) - .

Q protected
Q protected
;
Q protected
Q protected
.

byte[] buf - ;
int count - int mark - ;
int pos - -

java.io

2.3.1. Data Input

boolean readBoolean ( ) 0, true, false;


Q byte readByteO - ;
char readChar ( ) - ;
G void. readFully (byte [] b) - , ;
Q void readFully (byte [] b, int o f f , int len) -
len ;
Q Int readlnt ( ) - int
( );
Q long readLong ( )
long ( );
Q short readshort ( )
short ( );
int readUnsignedByte ( ) - 0 256;
int readUnsignedShort ()- , 0 256;
Q String readUTF ()- UTF-8;
Q int skipBytes (int n) - , .

2.3.2. DataOutput
.

Q void write (byte [] b) - ;


void write (byte [] b, int o f f , int len) - 1 en b ;
void write (int b) -
;
G void writeBoolean (boolean v).- ;
void writeByte (int v) -
;
ED void writeChar (int v) - char ( - );
Q void writeChars (String s) -
;

Java 2 Micro Edition


Enumeration elements () - '
;
void ensureCapacity (int minCapacity) ;
Q Object f irstElement ( ) - -
;
int indexOf (Object elem) - ;
Q int indexOf (.Object elem, int index) - ;
.Q void insertElementAt (Object obj , int index)
;
Q boolean isEmpty()- , ;
Q Object lastElement ( ) -
;
Q int lastlndexOf (Object elem) - ;
Q int lastlndexOf (Object elem, int index) -
;
Q void removeAllElements ( ) - ;
Q boolean removeElement (Object obj ).- ;
void , removeElement At (int index) -
;
Q void setElementAt (Object obj , int index), - ;
Q void setSize(int newSize) - ;
Q int size () - ;
G String toStringO -
;
G void trimToSize() - .

Q protected int capacitylncrement -


, ;
Q protected int elementCount ;
G protected Obj ect [ ] elementData - , .

2.2.11.
EmptyStackException - ;
Q NoSuchElementException - .

2.3. Java.io

.

java.util

boolean cancel () - ;
Q abstract void run ( ) - ;
Q long scheduledExecutionTime() -
.

2.2.9. TimeZone
.

TimeZone ( ) - TimeZone.

Q static S t r i n g E ] getAvailablelDs (} - ;
s t a t i c TimeZone getDefault ()- ;
D String getlDO - ;
abstract int getRawOf f set ( ) - ;
Q static TimeZone getTimeZonef String ID) - ;
Q abstract boolean useDaylightTime ()- .

2.2.10. Vector
. .

Q Vector ( } - ;
Q Vector (int initialCapacity) - ;
Q V e c t o r ( i n t initialCapacity, int.capacitylncrement)- ;

>
Q void addElement (Object obj ) -
;
Q int capacity () -
;
Q boolean contains (Object elem) -
;
Q void copylnto (Object [ ] anArray) -
;
Q Object elementAt (int index) -
;

Java 2 Micro Edition

2.2.6. Stack
.

Q Stack () - .

Q boolean empty () - ;
. Q Object peek () - ;
Q Ob j ect pop ( ) - ;
Q Object push (Object item) - ;
Q int search (Object )-
.

2.2.7. Timer
.

Timer () - .

Q void cancel () ;
Q void schedule (TimerTask task, Date time) -
;
Q void schedule(TimerTask task,
Date f i r s t T i m e ,
long
period) - , . ;
Q void schedule (TimerTask task, long delay) - ;
Q void schedule(TimerTask task, long delay, long period)
, .
.;
Q void scheduleAtFixedRate(TimerTask task, Date f i r s t T i m e ,
long period)
.
;
Q void scheduleAtFixedRate(TimerTask task, long delay, 'long
period) - .
.

2.2.5. TimerTask
. ;

Q protected TimerTask () - .

java.util

Q HashtableO - Hashtable;
Q Hashtable (int i n i t i a l C a p a c i t y ) - Hashtable .

void clear () - Hashtable- ;


Q boolean contains (Object value) -
;
boolean containsKey (Object key) - ;
Q Enumeration
elements () ;
Object get (Object key) - ^
;
U boolean isEmpty() - Hashtable
;
Q Enumeration keys -
;
Object put(0bject key, Object value) - ;
Q protected void rehash () -
Hashtable;
Q Object remove (Object key) - ;
int size () - ;
Q String toStringO -
Hashtable.

2.2.5. Random
.

',
Q Random ( ) - ;
Q Random (long seed) - Random, .

Q protected int next (int bits) -


;
int nextInt ( ) - ;
long nextLong ( ) - ;
Q void setSeeddong seed) -
.

Java 2 Micro Edition


Q
Q

Q
Q
Q
Q

Q
Q
Q
Q
Q
Q

Q
Q
Q

static int DECEMBER - , ;


static int FEBRUARY - , ;
static int FRIDAY - , ;
static int HOUR - , ;
static int HOUR_OF_DAY - , ;
static int JANUARY - , ;
static int JULY - , ;
static int JUNE - , ;
static int MARCH - , ;
static int MAY - , ;
static int MILLISECOND - ;
static int MINUTE - ;
s t a t i c int MONDAY - , ;
static int MONTH - ;
static int NOVEMBER - , ;
static int OCTOBER - , ;
static int PM - , ;
static int SATURDAY - , ;
static int SECOND - ;
static int SEPTEMBER-, ;
static int SUNDAY - , ;
static int THURSDAY - , ;
static int TUESDAY - , ;
static int WEDNESDAY - , ;
static int YEAR - , .

2.2.3. Date
.

Q Date ( ) - Date;
Date (long date) - Date
00:00:00.

boolean equals (Object ohj ) - ;


long getTime ( ) - ;
Q int
hashCode ( ) - (-)
Date;
Q void setTimedong time) - .

2.2.4. Hashtable
.

java.util
Q Object nextElement { ) - , .

2.2.2. Calendar
, .

protected Calendar () - . .

boolean after (Object when) -


true , when, ;.
G boolean before (Object when) - true , when,
;
Q boolean equals (Object obj ) - ;
Q . i n t get (int f i e l d ) - , , , , , ;
Q static Calendar getlnstance ( ) - ;
Q static Calendar getlnstance (TimeZone zone) - ;
Date getTime ( ) - ;
protected long getTimelnMillis ( ) ,
;
Q TimeZone getTimeZone ( ) - ;
Q void s e t ( i n t f i e l d , int v a l u e ) - ;
Q void setTime (Date date) - ;
Q protected void setTimelnMillis (long m i l l i s ) -
, ;
Q void setTimeZone (TimeZone value)
.

Q static int AM - , ;
Q static int AM_PM - ,
;
Q static int APRIL - , ;
Q s t a t i c int AUGUST -, ;
Q static int DATE - , ;
static int DAY_OF_MONTH - , ;
Q s t a t i c int DAY_OF_WEEK - , ;

Java 2 Micro Edition

2.1.17.
Q Exceptions - ;
Q ArithmeticException - ;
ArrayIndexOutOf BoundsException -
' ;
L3 ArrayStoreException - ;
ClassCastException - ;
Q ClassNotFoundException - ;
Q IllegalAccessException - ;
Q 111 ega I Argument Exc ept ion- ;
Q IllegalMonitorStateException - ;
IllegalStateException - ;
Q IllegalThreadStateException - ;
Q IndexOutOf BoundsException - ;
Q InstantiationException - ;
InterruptedException -
:
NegativeArraySizeException -
, ;
Q NumberFormatException - ;
RuntimeException.- Java;
Secur ityExcept ion - ;
Q StringlndexOutOf BoundsException -
.

2.1.18.
Q Error - ;
Q OutOf Memory-Error - ;
Q VirtualMachineError - .

2.2. java.util
Java 2 ME
. Java 2 SE.

2.2.1. Enumeration
.

Q boolean hasMoreElements ( ) - ;

Java.long

2.1.15. Thread
Java , . .

Thread ( ) - ;
Q Thread(Runnable target) - target,
Runnable.

Q static int act iveCount ( ) - ;


Q static Thread currentThread() -
;
Q int getPriority ( ) - ;
boolean isAliveO - ;
Q void join - ;
Q void setPriority (int 'newPriority) -
;
Q static void sleep (long m i l l i s ) - , , ;
Q void start ( ) -
run () Runnable;
Gl String toSt ring ()- ;
G static void yield () - .

static int MAX_PRIORITY - ;


Q static int MIN_PRIORITY ;
Q static int NORM_PRIORITY - .

2.1.16. Throwable
\

, Java.

Q Throwable () - Throwable;
Q Throwable (String message) - Throwable .

Q String getMessageO - ;
Q void printStackTrace ( ) - ;
Q String toStringO - Throwable.

Java 2 Micro Edition


Q void getCh'ars (int srcBegin, int srcEnd, char[] dst, int
dstBegiri) - ;
S t r i n g B u f f e r . i n s e r t ( i n t o f f s e t , boolean b ) -
boolean b;
Q StringBuf fer insert (int o f f s e t , ch'ar ) -
;
Q StringBuffer insert(int o f f s e t , char[] str) -
char [ ] str;
Q StringBuffer insert (int o f f s e t , int i) -
int;
StringBuffer insert(int o f f s e t , long 1)-
long;
Q StringBuffer insert(int o f f s e t , Object o b j ) -
;
Q StringBuffer insert(int o f f s e t . String str) -
;
Q int lengthQ - ;
StringBuffer reverse () - ;
Q void setCharAt (int index, char ch) -
;
void setLength(int newLength) -
;
Q String toString() - .

2.1.14. System
.

Q static void arraycopy(Object src, int src oosition.


Object dst, int dst_position, int length) -
;
static long currentTimeMillis ( ) - ,
;
Q static void exit (int status) - ;
Q static void gc ( ) - ;
Q static String getProperty (String key) - ;
static int identityHashCode (Object x)-
(-) .

static PrintStream err - , ;


D static PrintStream out - .

Java.long
Q s t a t i c String valueOf (int i) - int;
Q static String valueOfdong 1)"- long;
Q static String valueOf (Object obj } - .

2.1.13. StringBuffer
S t r i n g B u f f e r .

Q S t r i n g B u f f e r O - , S t r i ngBu f f e r,
, ;
Q StringBuffer (int length) - StringBuffer
;
StringBuffer (.String str) - StringBuffer
str, ^ t r ing.

Q StringBuffer append (boolean b) - ;


Q StringBuffer append (char ) - ;
Q StringBuffer append (char [ ] str) - ;
Q StringBuffer append(char[] str, int o f f s e t , int len) ;
G StringBuffer append (int i) -
int ;
ID StringBuffer append (long 1) -
long ;
Q StringBuffer append (Object obj) -
;
Q StringBuffer append(String str) - ;
Q int capacityQ - ;
char c h a r A t ( i n t index) -
index;
Q StringBuffer delete (int start, int end) -
start end;
StringBuffer deleteCharAt (int index) - index;
Q void ensureCapacity (int minimumCapacity) - ;

Java 2 Micro Edition


int indexOf {int ch, int fromlndex)
fromlndex;
Q int indexOf (String str)-
;
Q int indexOf (String str , int fromlndex)
' fromlndex;
int lastlndexOf (irjt ch) ;
int lastlndexOf (int ch, int fromlndex) , fromlndex;
Q int length () - ;
boolean regionMatches(boolean ignoreCase, int t o f f s e t ,
String other, int oof f set, int 1 e n ) - . ;
Q String replace(char oldChar, char newChar) - oldChar
newChar;.
Q boolean s t a r t s W i t h ( String p r e f i x ) - ;
Q boolean s t a r t s W i t h ( S t r i n g p r e f i x , int t o f f s e t ) -
;
Q String substring (int beginlndex) -
, ;
Q String substring(int beginlndex, int endlndex) -
, ;
Q char [ ] ^toCharArray ( ) ;
String toLowerCase() - ;
Q String t o S t r i n g ( ) - ;
Q String toUpperCase ( ) - ;
Q String trim ( ) - ;
Q static String valueOf (boolean b) - ;
Q static String valueOf(char ) - char;
Q static String valueOf (char [ ] . . data) -
char;
Q static String v a l u e O f ( c h a r [ ] data, int o f f s e t , int
count) -
char ;

'

Java.long
Q String (byte [] bytes) - String
;
Q String(byte[] bytes, int o f f , int len) -
String . o f f - , , len
;
Q String (byte [] bytes, int o f f , int len, String enc) -
String . o f f -
, , len
;
Q String (by te [] bytes, String enc) - String
;
String (char [] value) - ;
Q String : (char [] value, int o f f s e t , int c o u n t ) -
. o f f s e t -. count - ;
Q String (String value) - String
value;
Q String (StringBuf fer b u f f e r ) - String
buffer,
StringBuffer.

Q char char At (int index) -


index, 0;
Q int compareTo (String anotherString) -
;
Q String concat (String str) - ;
Q boolean endsWith( String suffix)-
s u f f i x ;
Q boolean equals (Object anObject) - ;
Q byte [ ] getBy tes ( ) - ;
D byte[] getBytes (String enc) - ;
Q void getCharstint srcBegin, int srcEnd, char[] dst, int
dstBegin) - ' ;
int hashCode ( ) - (-)
;
Q int indexOf (int ch) - ;

Java 2 Micro Edition


Q void wait (long timeout, int nanos) -
, .

2.1.10. Runtime

' , i

Q void exit (int s t a t u s ) - ;


Q long f reeMemory ( ) - ;
void gc { ) - ;
Q s t a t i c Runtime getRuntime ()- ;
long totalMemory ( ) - Java .

2.1.11. Short
- - Short.

Short (short value) - Short.

u boolean equals (Object obj ) - ;


Q int hashcode ( ) - (-)
Short;
Q static short parseShort (String s) -
String;
Q static short parseShort (String s, int radix) -

- String;
short shortValue ()- ;
! String toString ( ) - String .

s t a t i c short MAX_VALUE - ;
Q static short MIN_VALUE - .

2.1.12. String
.

String ( ) - String,
;

Java.long
s t a t i c long parseLong(String s, int radix) - String;
String toString ( ) - String ;
Q. s t a t i c String toStringdong i)-
String ;
Q static String toStringdong i, int radix) -
.

Q static long MAX_VALUE - ; i


G static long MIN_VALUE - .

2.1.8. Math
, . Math Java 2 SE.

Q static int abs(int a) - int ;


,Q static long abs(long a) - long ;
Q static int max ( i n t a, int b ) -
int;
Q static long max (long a, long b ) -
long;
Q static int min(int a, int b) -
int;
static long mindong a, long b)
long.

2.1.9. Object
Java. Ob j ect

Q boolean equals (Object obj ) - ; Q Class getClass ( ) - ;


Q int hashCode ( ) - (-) ;
Q void n o t i f y () - ;
Q void n o t i f y A l l ( ) - ;
Q String toString ( ) -
;
Q void wait () - ;
void wait (long timeout) -
;

Java 2 Micro Edition


int intValue ( ) - int;
long longValueO - long;
static int parselnt (String s) -
String;
Q static int parselnt (String s, int radix) -
String;
Q short s h o r t V a l u e ( ) - short;
static String toBinaryString(int i) - ;
Q static String toHexString (int i) - ;
Q static String toOctalString (int i) - ;
String toString ( ) - String, ;
static String toString (int i) -
string ;
Q static String toStri'ng(int i, int radix)
;
Q static Integer valueOf (String s) -
Integer, s;
static Integer valueOf (String s, int radix) -
Integer, s .

D static int MAX_VALUE - ;


G static int MIN_VALUE - .

2.1.7. Long
- - long.

Q Long (long value) - Long.

Q boolean equals (Object obj ) - ;


Q int
hashCode ( ) - (-)
Long;
Q long longValueO - long;
Q static long parseLong( String s) - String;

Java.long
Q s t a t i c char toLowerCase (char ch) -
;
String toStringO - String, Character;
static char toUpperCase (char ch) -
.
i

0 static int MAX_RADIX - ;


U static char MAX_VALUE - ;
01 static int MIN_RADIX - ;
Q static char MIN_VALUE - .

2.1.5. Class
Java , Java.

Q static Class forName (String className) -


Class, ;
Q String getName ( ) - , , , Class;
Q InputStream getResourceAsStream(String name) - ;
boolean isArray ( ) , ;
Q boolean isAssignableFrom(Class els) - ,
;
Q boolean islnstance (Object obj )- ;
boolean islnterf ( ) - , ;
, - Q Object newlnstance ( ) - ;
Q String toString()- String.

2.1.6. Integer
- int.

^
Integer ( i n t value) - Integer.

Q byte byteValue ( ) - ;
boolean equals (Object obj) - ;
Q int
hashCode ( ) - (-)
Integer;

- -

.

.
DirectX 9. C++.
:
Java2ME@mail.ru.

Java 2 ME

Java 2 Micro
Edition,
.

Java 2 ME,
MIDP 1.0 MIDP 2.0,

.
,
,
, .

, ,
Java 2 ME.

. .

/
/

-
,

: Sun
ONE Studio 4 Mobile Edition J2ME Wireless
Toolkit 2.1 Sun Microsystems
Nokia, Siemens,
Sony Ericsson, Motorola, Samsung.
Internet-
www.abook.ru
e-mail: orders@abook.ru

ISBN 5-94074-279-3

Web-
www.dmkpress.ru
-
. 103001. , / 82
.: (095) 258-9194, 258-9195

9 "785940||742791|

: /

Оценить