‘ŸĶ‹ ’‚ž™‚†›
ڟ Ķ…Š› Ķßԃ ą— Å‹Į ąĖŒ ąĖĮĖ Ž‚Œœ HelloWorld ܂†› ĪĮ ąœß›œ ڟ ÜŸĢ ĶĖ
ĖßéŒ’é› Į͇Į ܟ‚ƒß› ПĮßŸĖ ’ßĶ Ķƒ ą— ’Įą›‚œĶƒ ąƒ .ĖĖ’› Ž‚Œœ ĮĶ midlet
ß ‚靱ĖĮĖ ß ĶéƒĶ‚é— ԃĮĶ ą— Å‹Į ’…™„Į ˜œ‚› midlet .Ėߌ’› ą…•˜ Midlet
.Ėߌ ’› ܛ‚Œ ĮĶ ’™Ķ…œ— ’‚’Ÿ‚œĮ߅

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class HelloMidlet extends MIDlet implements CommandListener
{
// Initialize the Midlet Display variable
private Display midletDisplay;

// Initialize a variable for the doneCommand
private Command doneCommand;

public HelloMidlet()
{
// Retrieve the display from the static display object
midletDisplay = Display.getDisplay(this);

// Initialize the doneCommand
doneCommand = new Command("DONE", Command.SCREEN, 1);
}

/**
* Create the Hello Midlet World TextBox and associate
* the exit command and listener.
*/
public void startApp()
{
// Create the TextBox containing the "Hello Midlet World!!" message
TextBox textBox = new TextBox("Hello Midlet", "Hello Midlet World!!", 256, 0);

// Add the done Command to the TextBox
textBox.addCommand(doneCommand);

// Set the command listener for the textbox to the current midlet
textBox.setCommandListener( (CommandListener) this);

// Set the current display of the midlet to the textBox screen
midletDisplay.setCurrent(textBox);
}

/**
* PauseApp is used to suspend background activities and release
* resources on the device when the midlet is not active.
*/
public void pauseApp()
{
}

/**
* DestroyApp is used to stop background activities and release
* resources on the device when the midlet is at the end of its
* life cycle.
*/
public void destroyApp(boolean unconditional)
{
}

/*
* The commandAction method is implemented by this midlet to
* satisfy the CommandListener interface and handle the done action.
*/
public void commandAction(Command command, Displayable screen)
{
// If the command is the doneCommand
if (command == doneCommand)
{
// Call the destroyApp method
destroyApp(false);

// Notify the midlet platform that the midlet has completed
notifyDestroyed();
}
}
}


ąéŸéƒŒ ĪĮ screen capture ڟ ą— Å‹Į ąĖŒ ąĖĮĖ Ž‚Œœ ± ܗŒ ĶĖ Midlet ’‡ß͊
.ˌ‚ƒ’› J2ME Windows Toolkit Default GrayPhone Ī‚‹



ŠéŸé•Ķé…霟Į ¬MIDlet К— ’œ‚ƒŸ…Œ„ އ ĮĶ Midlet ąĻŸß ’‚ž‹š— ¬ÜßĮ Ԋ ßĖ
ĶĖ ‚éž‹š— ޟĮ .˜œ—’› ĖĶĮß ą›‚œĶƒ ąƒ ĶƒĶ‚— ԃĮĶ ’‚ž‹š— ß CommandAction
łéŸģ· ą™‚–› ޟĮ ĶĖ .˜ĶĮĖ ĶĮĶ– ą…•‚Ÿ ͟Ÿ“… ’Į߂‡ ‚ƒ ąĮĶ› ß MIDP API
.ˌ ĖĮߊ ʉƒ MIDP API ĶĖ Ė߇ߛ ’‚ž‹š— ĖĶߛ ĶĖ įĶ…ŒŸƒ


public class HelloMidlet extends MIDlet implements CommandListener

ß ß ąĖßéƒ Midlet Ššé— ĶĖ HelloMidlet Ššé— ąé— Ė韂é›éœ ’é› ŻšĮ Ԋ ޟĮ
Ššé— ĶĖ ĖŸ‚ƒ ‚Midlet ’›‚›… .˜— ’› ܂• ĮĶ CommanderListener П•Ķ…œŸĮ
‚éžéœĄ ÉéŸéŽßé… ąéƒ ÜéŸĢ ĶĖ ß ąĖßéƒ Ėé…é› ą‹ Ü›‚Œ ą— ĖœĶŸ˜ ĶĮĶ– MIDlet
:ݟĪĮĖĶ„’›


Method Name Method Purpose
startApp To allocate desired system resources and initialize the application.
pauseApp To temporarily suspend resource-intensive processes.
destroyApp To release resources used by the midlet and dispose of the midlet.


ĮĶéŸĪ ĖéŒ‚éƒ’é› ‚éžé…éŸé™éƒ‚é– ąé…‹Ė ڟ ܛ‚Œ startApp Ė…› ¬Üƒ– ܂†› ĶĖ
’‚靱ĶéŸéŠĢ ‚éŸ ąé—ƒŒ łԂƒ…ĶĮ ܟƒ– ĪĮ Ż…‹Ÿ‹ ͘ŸĖ ‘ƒ‚œ› ĪĮ HelloMidlet
ĮĖ startApp Ėߌ’› Į͇Į HelloMidlet ą—Ÿ›‚˜œ .˟‚›œ’›œ ąĖ‚•…‹Į ’…‚šŌĮ
.Ėߌ’› ąĖĪ

.ˌ ĖĮߊ Į͇Į startApp Ė…› ĪĮ ܃– Constractor ĖßĶ’› ͂ՅœĮ ą— ĶßԜ‚›
ąßšé .Ė霗’› Į˟„ Display ’ŸŒ ĪĮ ĮĶ ŃŸ‚›œ ą‰• Contractor ܂†› ޟĮ ĶĖ
.Ėߛœ ĖĮߊ initialize ĮĶ doneCommand Ž‚›Ķ• Constractor ŽĄ ̓

ĖĶßé› Midlet ’é‡ßĶéŠ Ń韂雜 ’Į̓ screen Ė‚‡ŸĮ އ Łß• startApp Ė…› ĪĮ
Ž‚éŒéœ ĮĶ TextBox screen ŽĖŒ initialize ÜŸĢ Ž‚›Ķ• .Ė͟˜’› ĶĮĶ– ąĖ‚•…‹Į
.ĖĖ’›


TextBox textBox = new TextBox("Hello Midlet", "Hello Midlet World!!", 256, 0);



ąé— Ė錂郒› ’›ĪŸœ‚—› Command .ˌ‚ƒ’› Commands ܛ‚Œ ޟœˆ› Midlet ą‰•
Ķ‚é—éƒ ąĖŒ ąĖĮĖ Ž‚Œœ š‚ƒ Š— ĶĖ ą—ŸĶßԃ ‚ž…‹Ÿ™ ß ‚ßœ› ąŸž… އ Midlet
ŽĖßĪé•Į ’Į̓ ąĖ‚•…‹Į ĖĶߛ Ė— ‚‡œŸĮ ĶĖ .ĖĖ͘’› ܂• Done ˟™— ‚ƒ ß ą…•Ķ
.ĖĖ͘’› ąģĮĶĮ Texbox ą‰• ąƒ Done ˟™—


// Add the done Command to the TextBox
textBox.addCommand(doneCommand);



ĶĖ .ĖßéŒ’é› ĶĖ‚ CommandActions Ž‚›Ķ• ¬ĖŸœ— ˟™— Command ’ßĶ Ķƒ ’›‚˜œ
ĖĶé— ĖĮߊ Į͇Į ĮĶ CommandListener П•Ķ…œŸĮ HelloMidlet ¬ąĖ‚‹ ܂†› ޟĮ
܂‰ ĶĖ Ż…‹Ÿ‹ ڟ ą—Ÿģ‚‡œĄ ĪĮ .˜— ’› ÜĶ…œ— ĮĶ ‚ĖĮĖŠĶ ąŸ™— ß…Ķ… ޟ˃ ß
.Ė߃ ĖĮߊ ˟•› ąĖĶ…‹˜ ÉŌ‹ ڟ ĶĖ ‚ĖĮĖŠĶ ÜĶ…œ— ¬ĖœßŒ’› Ķ…ąĖŸˆŸ„ ą‹ß…

// Set the command listener for the textbox to the current midlet
textBox.setCommandListener( (CommandListener) this);



ą‚˜…‹Ė џ‚›œ ą‰• ’ßĶ Ķƒ џ‚›œ ąĖ‚›Ą ¬ĖŸĮąĖߛœ Ė‚‡ŸĮ ĮĶ TextBox ą— Ü‚‰
.ĖĶ— ŻĮߊ ݟ՜… ĖŸĖ‡ TextBox ’ßĶ ĮĶ ŃŸ‚›œ ą‰• Ž› ÜŸĢ ŌŠ ĶĖ .ˌ‚ƒ’›

// Set the current display of the midlet to the textBox screen
midletDisplay.setCurrent(textBox);



MIDP ŻĶ•…š„ ĶĖ ą— Šš— ˜ˆ ĪĮ Ō–• ą— Å‹Į ąĖ‚‹ Ķ‚Ÿ‹ƒ ąœß›œ ڟ HelloWorld
ĮĶ MIDP API ’‚靱éß›‡›ĶŸĪ ĪĮ ’—Ÿ ą›ĮĖĮ ĶĖ .˟‚›œ’› ąĖ‚•…‹Į ¬ĖĶĮĖ Ė߇ß
.ŻĖ ’› ɟŽß… ‚›Œ ’Į̓



ÜßĮ ъƒ ܗ
1 2 3 4 5

’‡œ‹Ķ՜
ޟĮ ĖĶߛ ĶĖ ĮĶ Ėߊ Ķ՜
:˟Ÿß˜ƒ ‚› ąƒ Ć™Ō›

ŃĪĶĮ ‚ƒ ’™ŸŠ -
ŃĪĶĮ ‚ƒ -
ŃĪĶĮ’ƒ -

’œ šßŌ ’™ŸŠ -
Ƌ‚œ› -
ą‚…ß— -

’Š… ’™ŸŠ -
Ćߙԛ -
ŋŸœ ’Š… ’•‚— ąĪĮ˜Į ąƒ -


:Ż‚œ

:ڟœßĶ…—™Į ŋ„

: Å—ĶŒ Ż‚œ

܃– ’‚Å›‹–
ÜßĮ ś‹– - MIDP ‚ƒ ПĮßŸĖ ’‹Ÿßœ ą›‚œĶƒ   
ŻßĖ Å›‹– - MIDP ‚ƒ ПĮßŸĖ ’‹Ÿßœ ą›‚œĶƒ   
Żß‹ ś‹– - MIDP ‚ƒ ПĮßŸĖ ’‹Ÿßœ ą›‚œĶƒ   
ŻĶ‚žˆ ś‹– - MIDP ‚ƒ ПĮßŸĖ ’‹Ÿßœ ą›‚œĶƒ   


Copyright 2001, IT World / JavaWorld / PC WORLD Iran/ International Data Group Inc. All rights reserved.