GAMBARAN UMUM APLIKASI KAMUS JERMAN-INDONESIA
Pada pembuatan aplikasi ini penulis menggunakan bahasa pemrograman Java versi 2 atau sering disebut dengan Java 2. Pada Java 2 terdapat tiga kategori yaitu Java 2 Standard Edition (J2SE), Java 2 Enterprise Edition (J2EE) dan Java 2 Micro Edition (J2ME). Dari ketiga bahasa pemrograman diatas dalam pembuatan aplikasi ini menggunakan Java 2 Micro Edition (J2ME) karena merupakan salah satu bagian dari tehnologi yang dikembangkan untuk memungkinkan aplikasi Java berjalan di perangkat Mobile seperti Telepon genggam, Palm, Pocket PC, dan sebagainya. Di dalam Java 2 Micro Edition (J2ME) terdapat suatu aplikasi yang disebut J2ME Wireless Toolkit yang digunakan untuk pengembangan aplikasi wireless dikarenakan memiliki beberapa emulator untuk menjalankan aplikasi wireless java yang telah dibuat. Pada kesempatan kali ini penulis membuat aplikasi J2ME yaitu kamus jerman- indonesia, yang bertujuan untuk mempermudah pembelajaran bahasa jerman pada aplikasi ini pengguna dapat mencari dari bahasa jerman ke indonesia ataupun sebaliknya.
TAMPILAN MIDLED DAN CODE
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.IOException;
public class andi_jerman extends MIDlet{
Display display;
MenuUtama menuUtama;
private Image imageDepan;
private Alert splash;
public andi_jerman() {
display = Display.getDisplay(this);
imageDepan = null;
try {
imageDepan = imageDepan.createImage("/res/ani.png");
} catch (IOException ioe) {
ioe.printStackTrace();
}
splash = new Alert(null, null, imageDepan, null);
splash.setTimeout(3000);
}
public void startApp() {
menuUtama = new MenuUtama(this, display);
display.setCurrent(splash, menuUtama);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void exitMIDlet() {
destroyApp(false);
notifyDestroyed();
}
};
Listing diatas merupakan awal dari menu utama atau midlet aplikasi kamus ini.
CODE MENU UTAMA
import javax.microedition.lcdui.*;
import java.io.IOException;
class MenuUtama extends Form implements CommandListener {
private Display display;
private andi_jerman midlet;
private about about;
private ReadFilterStoreIJ rfsIJ;
private ReadFilterStoreJI rfsJI;
private Image imageMenu;
private ChoiceGroup pilihan;
private String[] menu = {" Indonesia - Jerman", " Jerman - Indonesia"};
private final Command cmdOk = new Command("Ok", Command.SCREEN,1);
private final Command cmdAbout = new Command("About", Command.SCREEN,1);
private final Command cmdKeluar = new Command("Exit", Command.EXIT,1);
public MenuUtama(andi_jerman midlet, Display display) {
super("My Dictionary");
this.display = display;
this.midlet = midlet;
/*logo menu*/
imageMenu = null;
try {
imageMenu = imageMenu.createImage("/res/menu.png");
} catch (IOException ioe) {
ioe.printStackTrace();
}
ImageItem imageItem = new ImageItem(null, imageMenu, ImageItem.LAYOUT_CENTER, null);
append(imageItem);
/*tampil pilihan*/
pilihan = new ChoiceGroup("\n\nPilih Salah Satu ", Choice.EXCLUSIVE, menu, null);
append(pilihan);
addCommand(cmdOk);
addCommand(cmdAbout);
addCommand(cmdKeluar);
setCommandListener(this);
}
public void commandAction(Command c, Displayable s) {
if (c == cmdKeluar) {
midlet.exitMIDlet();
} else if (c == cmdOk) {
switch (pilihan.getSelectedIndex())
{
case 0 :
rfsIJ = new ReadFilterStoreIJ(this, display);
display.setCurrent(rfsIJ); break;
case 1 :
rfsJI = new ReadFilterStoreJI(this, display);
display.setCurrent(rfsJI); break;
}
} else if (c == cmdAbout) {
about = new about(this, display);
display.setCurrent(about);
}
}
}
Listing diatas digunakan untuk menjalankan menu utama.
CODE PENCARIAN KATA-KATA
import javax.microedition.lcdui.*;
class ReadFilterStoreIJ extends Form implements CommandListener {
private MenuUtama menuUtama;
private Display display;
private Command cmFind, cmKembali;
private StringItem si, item;
private TextField tfSearch;
public ReadFilterStoreIJ(MenuUtama menuUtama, Display display) {
super("Kamus Indonesia - Jerman");
this.display = display;
this.menuUtama = menuUtama;
int[] code; code= new int[130];
String[] indo = {"aku","selamat pagi","selamat siang","petualangan","berangkat","ijazah",
"menyalin","bagian","sendiri","semua","jadi","paling senang","yang lain","mulai","pemula",
"tawaran","rasa takut","berhenti","tiba","menelepon","melihat","menyapa","melelahkan",
"dokter","tugas","penuh perhatian","membenahi","bangun","mata","memanggang",
"tukang roti","bangku","baterai","pembangunan","membangun","merawat","mendapatkan","pekerjaan","tempat tidur","bir",
"membentuk","lantai","roti","kantor","peluang","pimpinan","paduan suara","komik","karena","kali ini",
"direktur","dosen","sebenarnya","mudah","es krim","ahli listrik","orang tua","pada akhirnya","memaafkan","terkejut",
"keberhasilan","hasil","diperbolehkan","tidak mungkin","makan","kesalahan","selesai","membiayai","menemukan","perusahaan",
"bentuk","persahabatan","damai","makan pagi","sama sekali tidak","taman","tamu","kesabaran","senang","penghasilan",
"tepat","seperti saya","sudah muak","kecil","bahagia","memberi selamat","rambut","tangan","tas","kerja keras",
"rumah tangga","menikah","membantu","helm","kemeja","melihat","sore ini","di belakang","tinggi","pesta perkawinan",
"berharap","harapan","mengambil","celana panjang","ahli komputer","insinyur","kepentingan","berminat","internasional","setiap orang",
"pekerjaan","kopi","anak","bioskop","gaun","pakaian","perawat","hidup","kesayangan","pelukis",
"orang","ahli mesin","ibu","nama","pesta","psikolog","saran","agama","tenang","bersih"};
String[] jerman = {"ich","guten morgen","guten tag","abenteuer","abfahren","abschluss","abschreiben","abteilung",
"allein","alles","also","am libsten","ander","anfangen","anfanger","angebot","die angst","anhatten","ankommen","anrufen",
"anschauen","ansprechen","anstrengand","r arzt","aufgabe","aufmerksam","aufraumen","aufstehen","auge","backen",
"backer","bank","batterie","bau","bauen","behandeln","bekommen","beruf","bett","bier",
"bilden","boden","brot","buro","chance","chef","chor","comic","denn","diesmal",
"direktor","dozent","eigentlich","einfach","das eis","elektriker","die eltern","endlich","entschuldigen","entsetzt",
"erfolg","ergebnis","erlaubt","es geht nicht","essen","fahler","fertig","finanzieren","finden","firma",
"form","freundschaft","der friede","fruhstucken","ger nicht","garten","gast","die geduld","gefallen","gehalt",
"genau","genau wie ich","genug haben","gering","glucklich","gratulieren","haar","hand","handtasche","hart arbeiten",
"haushalt","heiraten","helfen","helm","hemd","herschauen","heute nachmittag","hinter","hoch","hochzeit",
"hoffen","hoffnung","holen","hose","informatiker","ingenieur","interesse","interessieren","international","jeder",
"job","der kaffee","kind","kino","kleid","die kleidung","krankenschwester","leben","lieblings","maler",
"man","mechaniker","mutter","name","party","psychologe","der rat","religion","ruhig","sauber"};
Save save = new Save("db_data");
save.open();
save.saveRecordStream(code, indo, jerman, 0);
save.close();
tfSearch = new TextField("Masukan Kata : \n", "", 20, TextField.ANY);
append(tfSearch);
cmFind = new Command("cari", Command.OK, 1);
cmKembali = new Command("Kembali", Command.BACK, 1);
setCommandListener(this);
addCommand(cmFind);
addCommand(cmKembali);
si = new StringItem("", "");
append(si);
}
public void search(){
Save save = new Save("db_data");
save.open();
if (tfSearch.getString() == null) {
si.setLabel("Harap masukan kata \n");
}
String result = save.readRecordStreamIJ(tfSearch.getString());
if(result != null){
si.setLabel("Hasil Pencarian \n");
si.setText(result);
}else{
si.setLabel("Hasil Pencarian \n");
si.setText("tidak ditemukan");
}
save.close();
}
public void commandAction(Command c, Displayable s) {
if (c == cmKembali){
Save save = new Save("db_data");
save.delete();
display.setCurrent(menuUtama);
} else if(c == cmFind){
search();
}
}
};
Listing diatas digunakan untuk masukan kata dari bahasa indonesia ke jerman dan mencarinya jika kata ditemukan
APLIKASI KAMUS JERMAN-INDONESIA WITH J2ME
Diposting oleh
andi hakim nasution
|
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar