Dari mailing list: netbeans-indonesia
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author Sapto Sutardi Fakultas Kedokteran Univ. Mataram
*/
public class KamusSasakIndo extends MIDlet implements CommandListener {
public Form frSasak, frIndo;
public Display display;
public Command cmTransSasak, cmTransIndo, cmExit, cmBackSasak, cmBackIndo, cmKeUtama;
public TextField tfSasak, tfIndo;
public TextBox tbSasak, tbIndo;
public List lsUtama;
public Alert alNotFound;
public String[] sasak = {"uwah", "mangan", "side", "tidoq", "ende ne", "araq", "kepeng"};
public String[] indo = {"sudah", "makan", "anda", "tidur", "tidak", "ada", "uang"};
public KamusSasakIndo(){
display = Display.getDisplay(this);
alNotFound = new Alert("Maaf", "Kata yang Anda cari ndeq ne araq.", null, AlertType.INFO);
alNotFound.setTimeout(3000);
}
public void startApp() {
get_lsUtama();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void exitMIDlet() {
display.setCurrent(null);
destroyApp(false);
notifyDestroyed();
}
public void commandAction(Command c, Displayable d) {
if(c == cmTransSasak){
String sSasak = tfSasak.getString().toLowerCase();
for(int i =0; i
if(sSasak.equals(sasak[i])){
System.out.println("Posisi :"+i);
get_vSasak();
tbSasak.setString(indo[i]);
break;
} else {
display.setCurrent(alNotFound);
}
}
}
if(c == cmTransIndo){
String sSasak = tfIndo.getString().toLowerCase();
for(int i =0; i
if(sSasak.equals(indo[i])){
System.out.println("Posisi :"+i);
get_vIndo();
tbIndo.setString(sasak[i]);
break;
} else {
display.setCurrent(alNotFound);
}
}
}
else if(c == cmExit){
destroyApp(false);
notifyDestroyed();
}
else if (c == List.SELECT_COMMAND) {
if (d == lsUtama){
switch (lsUtama.getSelectedIndex()) {
case 0: {
get_Sasak();
break;
}
case 1: {
get_Indo();
break;
}
}
}
}
else if(c == cmBackSasak){
display.setCurrent(frSasak);
}
else if(c == cmBackIndo){
display.setCurrent(frIndo);
}
else if(c == cmKeUtama){
get_Sasak();
display.setCurrent(lsUtama);
}
}
public List get_lsUtama(){
lsUtama = new List("Kamus Sasak Indo", List.IMPLICIT);
lsUtama.append("Sasak -> Indo", null);
lsUtama.append("Indo -> Sasak", null);
cmExit = new Command("Keluar", Command.EXIT, 1);
lsUtama.addCommand(cmExit);
lsUtama.setCommandListener(this);
display.setCurrent(lsUtama);
return lsUtama;
}
public Form get_Sasak(){
frSasak = new Form("Sasak -> Indo");
tfSasak = new TextField("Kata Sasak", null, 20, TextField.ANY);
cmTransSasak = new Command("Terjemah", Command.SCREEN, 1);
cmKeUtama = new Command("Kembali", Command.SCREEN, 2);
frSasak.append(tfSasak);
frSasak.addCommand(cmTransSasak);
frSasak.addCommand(cmKeUtama);
frSasak.setCommandListener(this);
display.setCurrent(frSasak);
return frSasak;
}
public Form get_Indo(){
frIndo = new Form("Indo -> Sasak");
tfIndo = new TextField("Kata Indo", null, 20, TextField.ANY);
cmTransIndo = new Command("Terjemah", Command.SCREEN, 1);
cmKeUtama = new Command("Kembali", Command.SCREEN, 2);
frIndo.append(tfIndo);
frIndo.addCommand(cmTransIndo);
frIndo.addCommand(cmKeUtama);
frIndo.setCommandListener(this);
display.setCurrent(frIndo);
return frIndo;
}
public TextBox get_vSasak(){
tbSasak = new TextBox(tfSasak.getString(), "", 100, 1);
cmBackSasak = new Command("Kembali", Command.SCREEN, 1);
tbSasak.addCommand(cmBackSasak);
tbSasak.setCommandListener(this);
display.setCurrent(tbSasak);
return tbSasak;
}
public TextBox get_vIndo(){
tbIndo= new TextBox(tfIndo.getString(), "", 100, 1);
cmBackIndo = new Command("Kembali", Command.SCREEN, 1);
tbIndo.addCommand(cmBackIndo);
tbIndo.setCommandListener(this);
display.setCurrent(tbIndo);
return tbIndo;
}
}
Bisa dikembangkan:
- Bahasa lain (misalnya Jawa –> Inggris), karena saya orang Sasak-Lombok jadi saya buat Sasak-Indonesia saja.
- Data kosa kata bisa ditaruh pada file terpisah dengan "getResourceAsStream"
- Menambah kosa kata dengan RMS.
- Pencarian dengan similiar text
- dll
Semoga bisa membantu yang membutuhkan.
Sapto Sutardi, Mataram NTB
============ ========= =====
Programmer untuk keperluan medis (+sesuai pesanan: Web & J2ME)
085 639 899 94, sapto_sutardi@yahoo.com
trimakasi postingannya bermanfaat Gan.
BalasHapusGan Nitip link y :)
bagi siapa aja yg mau shering ttg desain 3D bisa klik: http://www.bihum.blogspot.com