Pages

Tuesday, August 31, 2010

Bulding Graphical MIDlets

Numeric Color Component Values




Lines
Dipakai untuk menggambar garis.
Syntax: 
drawLine(int x1, int y1, int x2, int y2)
dimana x1, y1 adalah starting point dan x2, y2 adalah ending point.

Contoh:

public void paint(Graphics g) {
g.drawLine(5, 10, 15, 55);
}


Rectangles
Dipakai untuk menggambar persegi atau persegi panjang.

Syntax: drawRect(int x, int y, int width, int height)

Contoh:

public void paint(Graphics g) {
g.drawRect(5, 10, 15, 55);
}


Arcs
Dipakai untuk menggambar sudut.

Syntax: drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)


Contoh:

public void paint(Graphics g) {
g.drawArc(5, 10, 150, 75, 95, 115);
}


Drawing Text
Dipakai untuk menambahkan teks.

Syntax: setFont(Font font)


Font getFont(int face, int style, int size)



The font face must be one of the following values: FACE_SYSTEM, FACE_MONOSPACE, or FACE_PROPORTIONAL.
The style of font must be one of the constants I mentioned earlier: STYLE_PLAIN or a combination 
of STYLE_BOLD, STYLE_ITALIC, and STYLE_UNDERLINED. T
he font size is specified 
as one of the following predefined constants: SIZE_SMALL, SIZE_MEDIUM, or SIZE_LARGE.


Contoh:

Font myFont = Font.getFont(Font.MONOSPACE, Font.LARGE, Font.BOLD | Font.UNDERLINED);


drawString(String str, int x, int y, int anchor)


An anchor point is associated with a horizontal constant and a
vertical constant, each of which determines the horizontal and vertical positioning of the 
text with respect to the anchor point. The horizontal constants used to describe an anchor 
point are LEFT, HCENTER, and RIGHT. One of these constants is combined with a vertical 
constant to fully describe an anchor point. The vertical constants are TOP, BASELINE, and 
BOTTOM.

Contoh:

g.drawString(“Look up here!”, getWidth() / 2, 0, Graphics.HCENTER | Graphics.TOP);


Drawing Images
 Dipakai untuk menambahkan image atau picture.
Contoh:
public void paint(Graphics g) {
// Clear the display

g.setColor(255, 255, 255); // White
g.fillRect(0, 0, getWidth(), getHeight());


// Create and load the image

Image img = Image.createImage(“Bull.png”);


// Draw the image

g.drawImage(img, getWidth()/2, getHeight()/2,

Graphics.HCENTER|Graphics.VCENTER);
}


Sumber: Sams Teach Yourself: Wireless Java With J2ME in 21 Days

Tuesday, August 24, 2010

MIDP-Specific Classes and Interfaces

This portion of the MIDP API is divided among several packages, all of which are prefixed with the javax.microedition name:
• javax.microedition.midlet
• javax.microedition.lcdui
• javax.microedition.io
• javax.microedition.rms

The javax.microedition.midlet Package
The javax.microedition.midlet package is the central package in the MIDlet API, and contains only one class: the MIDlet class. The MIDlet class provides the basic functional overhead required of a MIDP application (MIDlet) that can execute on a mobile device.

The javax.microedition.lcdui Package
The javax.microedition.lcdui package includes classes and interfaces that support GUI components that are specially suited for the small screens found in mobile devices.
Following are the interfaces defined in this package:
Choice—An interface that describes a series of items from which the user can
choose.
CommandListener—An event listener interface for handling high-level commands.
ItemStateListener—An event listener interface for handling item state events.

In addition to these interfaces, also several classes are in the javax.microedition.lcdui package:
Alert—A screen that displays information to the user, and then disappears.
AlertType—Represents different types of alerts used with the Alert class.
Canvas—A low-level drawing surface that allows you to draw graphics on the screen.
ChoiceGroup—Presents a group of selectable items; used in conjunction with the Choice interface.
Command—Represents a high-level command that can be issued from within a MIDlet.
DateField—Presents a date and time so that it can be edited.
Display—Represents a mobile device’s display screen, and also handles the retrieval of user input.
Displayable—An abstract component that is capable of being displayed; other GUI components subclass this class.
Font—Represents a font and its associated font metrics.
Form—A screen that serves as a container for other GUI components.
Gauge—Displays a value as a percentage of a bar graph.
Graphics—Encapsulates two-dimensional graphics operations such as drawing lines, ellipses, text, and images.
Image—Represents a graphical image.
ImageItem—A component that supports the layout and display of an image.
Item—A component that represents an item with a label.
List—A component consisting of a list of choices that can be selected.
Screen—Represents a full screen of high-level GUI information, and serves as the base class for all MIDP GUI components.
StringItem—A component that represents an item consisting of a label and an associated string of text.
TextBox—A type of screen that supports the display and editing of text.
TextField—A component that supports the display and editing of text; unlike TextBox, this component can be placed on a form with other components.
Ticker—A “ticker tape” component that displays text moving horizontally across the display.


The javax.microedition.io Package
CLDC lays the groundwork for networking and I/O with the java.io package and the Generic Connection Framework (GCF). The MIDP API builds on this support with the addition of the HttpConnection interface, which is included in the javax.microedition.io package. The HttpConnection interface solidifies the GCF with support for an HTTP connection, which is useful for accessing Web data from within a MIDlet.

The javax.microedition.rms Package
Because few mobile devices have hard drives or any tangible file system, you probably won’t rely on files to store away persistent MIDlet data. Instead, the MIDP API describes an entirely new approach to store and retrieve persistent MIDlet data: the Record Management System (RMS). The MIDP RMS provides a simple record-based database API for persistently storing data. The classes and interfaces that comprise the RMS are all located in the javax.microedition.rms package.
Following are the RMS interfaces found in this package:
RecordComparator—An interface used to compare two records.
RecordEnumeration—An interface used to iterate through records.
RecordFilter—An interface used to filter records according to certain criteria.
RecordListener—An event listener interface used to handle record change events.
In addition to these interfaces, a few classes fit into the RMS architecture. Most importantly, the RecordStore class represents a record store, which is essentially a simplified database for MIDlet data storage.

The following classes are included in the javax.microedition.rms package:
InvalidRecordIDException—Thrown whenever an operation fails because the record ID is invalid
RecordStore—Represents a record store
RecordStoreException—Thrown whenever an operation fails because of a general exception
RecordStoreFullException—Thrown whenever an operation fails because the record store is full
RecordStoreNotFoundException—Thrown whenever an operation fails because the record store cannot be found
RecordStoreNotOpenException—Thrown whenever an operation is attempted on a closed record store


Sumber: Sams Teach Yourself: Wireless Java With J2ME in 21 Days

Saturday, August 21, 2010

Menggunakan Eclipse Untuk Pengembangan Aplikasi Handphone Berbasis Java ME

Berikut adalah yang kita perlukan jika ingin mengembangkan aplikasi mobile berbasis Java ME dengan Eclipse:

Hal basis yang kita perlukan untuk mengembangkan aplikasi mobile menggunakan Java. Java SE SDK memberikan fungsi-fungsi dasar yang dibutuhkan oleh Java ME.
SDK ini hal yang wajib diinstal jika ingin mengembangkan aplikasi mobile berbasis Java. SDK ini selain menyediakan fungsi-fungsi untuk pengembangan aplikasi mobile juga menyediakan emulator untuk dapat menjalankan program yang sudah kita buat secara simulasi di komputer desktop.
Eclipse Pulsar, bagi yang sudah sering menggunakan Eclipse untuk mengembangkan aplikasi Java desktop, pasti tidak akan terlalu susah untuk beradaptasi dengan IDE yang satu ini. Eclipse Pulsar dibuat berbasis pada framework Eclipse. Eclipse Pulsar merupakan jembatan antara Java ME SDK dengan programmer. Saya menggunakan Eclipse Europa versi 3.3.2 karena belum terbiasa menggunakan Eclipse Pulsar. Namun, saya sarankan lebih baik menggunakan Eclipse Pulsar karena fitur-fiturnya terbarunya lebih baik daripada Eclipse Europa versi 3.3.2.

 
Langkah instalasi tool pengembangan aplikasi mobile berbasis Java ME:
1. Install Java SE SDK versi terbaru, ikuti petunjuk yang diberikan ketika melakukan proses instalasi.
2. Install Java ME SDK, ikuti petunjuk yang diberikan ketika melakukan proses instalasi.

Setelah kita menginstalasi segala yang kita butuhkan, sekarang saatnya kita mengkonfigurasikan Eclipse Europa versi 3.3.2 agar dapat menggunakan Java ME SDK, berikut adalah langkah-langkahnya:

1. Pilih menu Window>Preferences>J2ME>Device Management, di sini anda akan melihat interface mengenai perangkat emulator yang dapat digunakan untuk membuat aplikasi mobile. Awalnya daftar ini masih kosong oleh karena itu kita akan mengimpornya.



 2. Klik tombol Import lalu cari folder dimana anda menginstall Java ME SDK di komputer Anda dengan mengklik tombol Browse biasanya terletak pada folder root C:\WTK***.


3. Eclipse akan mendeteksi semua emulator yang ditemukan pada folder tersebut dan memberikan daftar emulator kemudian klik Finish.


4. Kita akan kembali lagi pada window Preferences kemudian klik OK.


Langkah pengkonfigurasian di atas dimaksudkan agar kita dapat mengemulasikan aplikasi mobile yang sudah kita buat pada komputer desktop. Sekarang kita sudah selesai mengkonfigurasi lingkungan pengembangan yang kita butuhkan untuk membangun aplikasi mobile.

Cara Membuka File Project JAVA ME di Eclipse Europa

Jika Anda sering menggunakan Eclipse Europa sebagai salah satu IDE tool selain NetBeans untuk membuat project Java ME tentunya bingung ketika akan membuka file project JAVA ME yang tersimpan di media penyimpanan seperti flashdisk.

Berikut ini adalah langkah-langkah membuka file project JAVA ME di Eclipse Europa:

1. Pada tab Package Explorer di sebelah kiri dari window editor klik kanan kemudian pilih menu Import.


2. Pada window Select Import Source kemudian pilih Existing Projects into Workspace.


3. Pada textbox Select root directory klik tombol Browse kemudian cari letak folder dimana Anda menyimpan  file project JAVA ME kemudian klik OK.


4. Anda akan kembali pada window Select Import Source, jangan lupa untuk memberi tanda centang pada checkbox Copy project into workspace agar file project J2ME Anda juga disimpan pada folder workspace Eclipse.


5. File project JAVA ME Anda kini telah muncul pada tab Package Explorer dan Anda dapat meng-edit coding pada window editor di sebelah kanan.

Friday, August 20, 2010

The MIDlet Life Cycle

MIDP applications are represented by instances of the javax.microedition.midlet.MIDlet class. MIDlets have a specific life cycle, which is reflected in the methods and behavior of the MIDlet class. A piece of device-specific software, the application manager, controls the installation, execution, and life cycle of MIDlets. MIDlets have no access to the application manager. A MIDlet is installed by moving its class files to a device. The class files will be packaged in a Java Archive (JAR), while an accompanying descriptor file (with a .jad extension) describes the contents of the JAR.

A MIDlet goes through the following states:

1. When the MIDlet is about to be run, an instance is created. The MIDlet’s constructor is run, and the MIDlet is in the Paused state.

2. Next, the MIDlet enters the Active state after the application manager calls startApp().

3. While the MIDlet is Active, the application manager can suspend its execution by calling pauseApp(). This puts the MIDlet back in the Paused state. A MIDlet can place itself in the Paused state by calling notifyPaused().

4. While the MIDlet is in the Paused state, the application manager can call startApp() to put it back into the Active state.

5. The application manager can terminate the execution of the MIDlet by calling destroyApp(), at which point the MIDlet is destroyed and patiently awaits garbage collection. A MIDlet can destroy itself by calling notifyDestroyed().


MIDlet Life Cycle

Sumber: Beginning J2ME: From Novice to Professional, Third Edition

Monday, August 16, 2010

Ganti Partition Magic dengan Freeware Easeus Partition Manager

Bagi yang sering utak-atik hardisk pasti tidak asing dengan program Partition Magic, software untuk mem-partisi hardisk dengan mudah. Saat ini (sebenarnya sudah agak lama ) ada alternatif gratis yang tidak kalah fiturnya. Easeus Partition Manager Home Edition, yang baru saja merilis versi terbarunya. Tampilannya pun mirip partition magic dengan fitur terbaru, yaitu Disk Copy Wizard, Partition Copy Wizard untuk memproteksi data dan mendukung hardisk yang berukuran 1.5 TG.

Software ini mendukung sistem operasi Windows 2000/XP/Vista. Bisa digunakan untuk Flashdisk, Hardisk PATA, SATA, STA II, SCSI,S-SATA Raid dan lainnya. Software ini bisa digunakan untuk memperbaiki hardisk yang terkena bad sector (secara software, bukan rusak fisik). Silakan download EASEUS Partition Manager dan nikmati fitur-fitur yang tidak kalah hebatnya dengan Partition Magic berbayar.

 Tampilan Window Easeus Partition Manager

Wednesday, August 4, 2010

RealVNC

VNC stands for Virtual Network Computing. It is remote control software which allows you to view and interact with one computer (the "server") using a simple program (the "viewer") on another computer anywhere on the Internet.

The two computers don't even have to be the same type, so for example you can use VNC to view an office Linux machine on your Windows PC at home. VNC is freely and publicly available and is in widespread active use by millions throughout industry, academia and privately.

This version includes both the VNC server and viewer.


 

Blogger news

About Me

My photo
Palembang, Sumatera Selatan, Indonesia
Seorang yang ingin terus belajar.