Laman

Sabtu, 23 Maret 2013

Mobile Java Programming - Class Alert

Assalamua'laikum wr.wb.

In the Last meeting  I have studied about mobile java programming is about Class Alert. An alert is a screen that shows data to the user and waits for a certain period of time before proceeding to the next Displayable. An alert can contain a text string and an image. The intended use of Alert is to inform the user about errors and other exceptional conditions.

The following is an example of script of Class Alert and also our task last meeting in the class of java programming.


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hello;

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

/**
 * @author JailaniLc
 */
public class Task_alert_modify extends MIDlet implements CommandListener {
Display display;
Form mainForm;
StringItem helloAlertString;
Command exitCommand = new Command ("Exit", Command.EXIT,1);
Command whyCommand = new Command ("Why?", Command.OK,1);
Command backCommand = new Command ("Back", Command.BACK,1);
Alert helloAlert;

public Task_alert_modify (){
helloAlertString = new StringItem("This is an example ","of the use of class Alert in java");
mainForm = new Form("Bahar Noer", new Item[] { helloAlertString});
mainForm.addCommand(exitCommand);
mainForm.addCommand(whyCommand);
mainForm.setCommandListener(this);
helloAlert = new Alert("Attention","An alert is a screen that shows data to the user and waits for a certain period of time before proceeding to the next Displayable", null,AlertType.INFO);
helloAlert.setTimeout(Alert.FOREVER);
helloAlert.addCommand(backCommand);
helloAlert.setCommandListener(this);
}
    public void startApp() {
if (display==null){
display = Display.getDisplay(this);
}
display.setCurrent(mainForm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d){
if (c == exitCommand){
destroyApp(true);
notifyDestroyed(); // Exit
}
if (c == whyCommand){
    display.setCurrent(helloAlert,d);
}
if(c == backCommand){
    display.setCurrent(mainForm);
}
    }

}

Simulator interface :

 1. Main view of simulator aplication .  Click on task_alert_modify .

Selasa, 19 Maret 2013

Cara Membuat Aplikasi Kalkulator Sederhana


Assalamu’alaikum Wr.Wb

Postingan kali ini saya akan mencoba memberikan kepada anda, bagaimana cara membuat aplikasi perhitungan yaitu membuat aplikasi Kalkulator.  Aplikasi kalkulator yang akan saya share adalah bentuk aplikasi kalkukalor sederhana. Dan  ini bisa anda gunakan untuk perhitungan dalam keseharian anda.
Ok, langsung saja langkah-langkahnya sebagai berikut :

     1.       Bukalah aplikasi visual basic 6.0 yang sudah terinstal pada PC anda.
     2.       Akan muncul kotak dialog New Project. Pilihlah Standart EXE lalu open.
     3.       Tambahkan beberapa objek ke dalam form, yaitu objek frame, 6 objek commandbutton, objek frame, 3 objek label, dan 3 objek textbox.
     4.       Kemudian Atur setiap properti form diatas seperti tabel berikut :
Komponen
Properti
Nilai
Form
Name
FmHitungan

Caption
HitunganSederhan
Frame
Name
Frame1
Label
Name
Label1

Caption
Bilangan 1
Label
Name
Label3

Caption
Bilangan 2
Label
Name
Label3

Caption
Hasil
CommandButton
Name
TbTambah

Caption
+
CommandButton
Name
TbKurang

Caption
-
CommandButton
Name
TbKali

Caption
X
CommandButton
Name
TbBagi

Caption
/
CommandButton
Name
TbC

Caption
C
CommandButton
Name
TbExit

Caption
Exit
Text
Name
TxtBil1
Text
Name
TxtBil2
Text
Name
TxtHasil

     5.       Lalu masuk kedalam halaman kode dan ketikkan kode program berikut secara lengkap

Option Explicit
Private Hasil As Double

' Untuk operasi pembagian
Private Sub TbBagi_Click()
    Hasil = Val(TxtBil1.Text) / Val(TxtBil2.Text)
    TxtHasil.Text = Hasil
End Sub

' Untuk operasi perkalian
Private Sub TbKali_Click()
    Hasil = Val(TxtBil1.Text) * Val(TxtBil2.Text)
    TxtHasil.Text = Hasil
End Sub

' Untuk operasi pengurangan
Private Sub TbKurang_Click()
    Hasil = Val(TxtBil1.Text) - Val(TxtBil2.Text)
    TxtHasil.Text = Hasil
End Sub

' Untuk operasi penambahan
Private Sub TbTambah_Click()
    Hasil = Val(TxtBil1.Text) + Val(TxtBil2.Text)
    TxtHasil.Text = Hasil
End Sub

' Untuk membatalkan semua operasi
Private Sub TbC_Click()
    TxtHasil.Text = ""
    TxtBil1.Text = ""
    TxtBil2.Text = ""
End Sub

' Untuk keluar dari form
Private Sub TbExit_Click()
    Unload Me
End Sub

      6.       Setelah selesai memasukkan semua kode program, jalankan program dengan menekan tombol F5. Berikut contoh hasil penjumlahan :

Contoh hasil aplikasi perhitungan
       
      semoga bermanfaat... :)