j2me তে হাতে খড়ি

Different কিছু শিখবো দেখেই আমরা কিছুটা different একটা প্রজেক্ট সিলেক্ট করেছিলাম(Location Based Services).প্রজেক্টের মুল concept টা এরকম যে location based advertising,emergency services etc using a mobile application+there will be also a web interface for the desktop clients.আমরা এ ব্যাপারে রনি ভাইএর সাহায্য নেই,

উনি আমাদেরকে প্রথম যে task দেন তা হল : UI design.
প্রথম প্রথম একটু ঝামেলা লাগলেও এখন দারুন মজা পাইতেছি 🙂
আমার প্রথম j2me UI code ছিলো এরকমঃ

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author mushfiq date:16-03-2010
*/
public class design extends MIDlet implements CommandListener{
private Display display;
private TextBox textbox1;
private Form form;
private Form form1;
private ChoiceGroup subject;
private int subjectindex;
private Command backcmd;
private Command formcmd;
private Command chckcmd;
private Command textcmd;
public void startApp()
{
display = Display.getDisplay(this);
formcmd = new Command("Form", Command.SCREEN, 0);
chckcmd = new Command("Check Box", Command.SCREEN, 1);
textbox1 = new TextBox("Text Box","Department of CSTE ", 80, 0);
backcmd = new Command("Quit", Command.SCREEN, 3);
textcmd = new Command("Text Box",Command.SCREEN, 2);
textbox1.addCommand(backcmd);
textbox1.addCommand(formcmd);//
textbox1.addCommand(chckcmd);
textbox1.setCommandListener(this);
// display.setCurrent(textbox1);

StringItem msg[] = new StringItem[2];
msg[0] = new StringItem(" Mushfiq","CSTE 2005-2006");
msg[1] = new StringItem("Rimon","Uttara");
form = new Form("Text Form 1", msg);
form.addCommand(backcmd);
form.addCommand(chckcmd);
form.addCommand(textcmd);
// form.addCommand(textbox1);
form.setCommandListener(this);
form1 = new Form("Check Box form");
form1.addCommand(backcmd);
form1.addCommand(textcmd);
form1.addCommand(formcmd);
form1.setCommandListener(this);

subject = new ChoiceGroup("Select your Department",Choice.MULTIPLE); //to use it as radio button have to use EXCLUSIVE
subject.append("CSTE",null);
subject.append("Pharmacy",null);
subject.append("ACCE",null);
subject.append("Microbiology",null);
subject.append("FIMS",null);
subjectindex = form1.append(subject);

display.setCurrent(textbox1);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c,Displayable displayable)
{
if(c == backcmd)
{
destroyApp(false);
notifyDestroyed();
}

else if (c == chckcmd)
{
display.setCurrent(form1);
}
else if (c == textcmd)
{
display.setCurrent(textbox1);
}
else if (c == formcmd)
{
display.setCurrent(form);
}
}
}


এই কোড টা run করলে দেখা যাবে text box,form,menu,check box,radio button.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s