Pages

Friday, October 22, 2010

First view of java mobile app code and change it

When you build a java mobile game in software(like netbeans IDE or eclipse..)

first thing you‘ll see is  a middlet class .Middlet class used for handling start and

initialize and interface of java mobile applications. In netbeans you have sample

screen that can add button or text or image or like that .just you should drag your desired items from right side to screen and then go to source

 

netbeansscreen

screen is interface of your project in netbeans

For example you  have pre defined string seeing in screen and want changed it when middlet started. Code is like this

public void startMIDlet() {
       // write pre-action user code here
       switchDisplayable(null, getForm());
             stringItem.setText("my name is dawood");
       // write post-action user code here
   }

startMIDlet is function that using in every middlet .In netbeans for adding interface to screen using a form , should calling when middlet started.For this purpose have this code switchDisplayable(null, getForm());

and then add this for changing text stringItem.setText("my name is dawood");

and run it in emulator

emulator1

in start for do more thing in java games you should add canvas class that i’ll describe later

No comments:

Post a Comment

linkwithin

Related Posts Plugin for WordPress, Blogger...