Jumat, 23 Desember 2011

Tugas Java Doa Sehari-hari

Untuk memenuhi tugas dari kuliah java berikut source code dan tampilan aplikasi dari kumpulan doa sehari-hari. Semoga bisa membantu teman2 yang ingin belajar membuat program java secara sederhana seperti ini :D

Aplikasi ini dibuat dengan menggunakan program NetBeans IDE 7.0.1... Cekediottttttt!!!!!!!!!

Tampilan Login :


Username : admin
Password : doaku

Tampilan Berhasil Login



Tampilan pilihan doa Sehari-hari



Tampilan Doanya




Source code :

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


public class Doaku extends MIDlet implements CommandListener {

private Display display;
private Form form1,form2,formlogin;
private TextField user, pass;
private Alert alert = new Alert("Messages");
private Ticker animasi;
private Command exit,proses,back,login;
ChoiceGroup cg = new ChoiceGroup("Pilih Doa", Choice.EXCLUSIVE);

public Doaku(){
}

public void startApp()
{
Display.getDisplay(this);
pass();
}

private void validateUser(String user, String pass)
{
if(user.equals("admin") && pass.equals("doaku"))
{
alert=new Alert("Berhasil", "Selamat Datang di Java Mobile", null, AlertType.WARNING);
alert.setTimeout(3000);
choice();
}
else
{
alert=new Alert("Error", "Periksa Username dan Password", null, AlertType.ERROR);
display.setCurrent(alert);
alert.setTimeout(3000);
}
}

public void commandAction (Command c,Displayable d)
{
if(c==exit)
destroyApp(true);
else if(c==proses)
proses();
else if(c==back)
display.setCurrent(form1);
else if (c==login)
validateUser(user.getString(), pass.getString());
}

public void choice () {
form1 = new Form ("Program Doa Harian");
exit = new Command ("Logout", Command.EXIT, 1);
proses = new Command ("Proses", Command.OK, 2);
animasi = new Ticker ("Suudiyah Norma Novida - 10201173/P");
form1.setTicker(animasi);
form1.addCommand(exit);
form1.addCommand(proses);
form1.setCommandListener(this);
cg.append("Doa Mau Makan", null);
cg.append("Doa Sesudah Makan", null);
cg.append("Doa Mau Tidur", null);
cg.append("Doa Bangun Tidur", null);
cg.append("Doa Keluar Rumah", null);
form1.append(cg);
Display.getDisplay(this).setCurrent(alert,form1);
}

public void proses (){
form2 = new Form("Proses");
form2.append("Bismillahirrahmanirrahim :");
animasi = new Ticker("Doa Sehari-hari By: Suudiyah Norma Novida - 10201173/P");
back = new Command("Back", Command.BACK, 1);
form2.addCommand(exit);
if(cg.isSelected(0))
{
form2.append(cg.getString(0));
form2.append(" الَّلهُمَّ بَارِكْ لَنَا فِيمَا رَزَقْتَنَا، وَقِنَا عَذَابَ النَّارِ , Alloohumma Baarik Lanaa Fiimaa Rozaqtanaa Waqinaa Adzaabannaar.");
}
else if(cg.isSelected(1))
{
form2.append(cg.getString(1));
form2.append(" الْحَمْـدُ للهِ الَّذي أَطْعَمَنـي وَسَقَانَا وَجَعَلْنَا مُسْلِمِينَ Alhamdulillaahil Ladzi Ath'amanaa Wa Saqaanaa Waja'alanaa Minal Muslimiin ");
}
else if(cg.isSelected(2))
{
form2.append(cg.getString(2));
form2.append("اسْمِكَ اللَّهمَّ أَمُوْتُ وَأَحْيَا. Bismika Allahumma Ahya Wabismika Amudz");
}

else if(cg.isSelected(3))
{
form2.append(cg.getString(3));
form2.append("الحَمْدُ للهِ الَّذِي أَحْيَانَا بَعْدَمَا أَمَاتَنَا وَإِلَيْهِ النُّشُورُ Alhamdulillaahil Ladzi Ahyana Bakdama Amatana Wailahin Nusur");
}

else if(cg.isSelected(4))
{
form2.append(cg.getString(4));
form2.append(" بِسْمِ اللَّهِ ، تَوَكَّلْتُ عَلَى اللَّهِ ، وَلا حَوْلَ وَلا قُوَّةَ إِلاَّ بِاللَّه Bismilaahi tawakkaltu 'alallahi wa laa hawla wa laa quwwata illaa billaahi");
}
form2.setCommandListener(this);
Display.getDisplay(this).setCurrent(form2);
form2.setTicker(animasi);
}

public void pass ()
{
formlogin = new Form("Sign in");
animasi = new Ticker("Form Login Doa Harian");
user = new TextField("Username :", "", 10, TextField.ANY);
pass = new TextField("Password :", "", 10, TextField.PASSWORD);
formlogin.append(user);
formlogin.append(pass);
formlogin.setTicker(animasi);
back = new Command("Cancel", Command.BACK, 1);
login = new Command("Login", Command.OK, 2);
formlogin.addCommand(login);
formlogin.setTicker(animasi);
formlogin.setCommandListener(this);
display = Display.getDisplay(this);
display.setCurrent(formlogin);
Display.getDisplay(this).setCurrent(formlogin);
}

public void destroyApp (boolean u)
{
notifyDestroyed();
}


public void pauseApp() {
}
}


Berikut link Downloadnya : Latihan Java.rar


Tidak ada komentar:

Posting Komentar