Published at: 05:11 am - Friday November 21 2008
Here is a suitable piece of HTML to test a simple HelloWorld class:
You can not see this brilliant Java Applet.
Test
Put this in a file called:
test.HelloWorld.html
The code for the HelloWorld applet has to be a public class called "HelloWorld" that extends Applet and is in in a Java file called:
HelloWorld.java
Here is the Java code:
import java.applet.*;
import java.awt.*;
public class HelloWorld extends Applet {
public void init() {
resize(150,25);
}/
Published at: 08:11 am - Thursday November 20 2008
Using images, tickers, and gauges as UI elements in MIDlets is quite straightforward. A gauge, as you saw in the last section, is an item that can only be displayed on a form to indicate progress or to control a MIDlet feature (like volume). A ticker, on the other hand, can be attached to any UI element that extends the Displayable abstract class, and results in a running piece of text that is displayed across the screen whenever the element that is attached to it is shown on the screen. Finally
Published at: 07:11 am - Thursday November 20 2008
A form is a collections of instances of the Item interface. The TextBox class (discussed in the preceding section) is a standalone UI element, while the TextField is an Item instance. Essentially, a textbox can be shown on a device screen without the need for a form, but a text field requires a form.
An item is added to a form using the append(Item item) method, which simply tacks the added item to the bottom of the form and assigns it an index that represents its position in the form. The fi
Published at: 07:11 am - Thursday November 20 2008
TextBox
Text is entered by the user using a textbox. Like the other UI elements, a textbox has simple features that can be set based on your requirements. You can restrict the maximum number of characters that a user is allowed to enter into a textbox, but you need to be aware of the fact that the implementation of this value depends upon the device that you are running it on. For example, suppose that you request that a textbox is allowed a maximum of 50 characters, by using setMaxSize(50),
Published at: 06:11 am - Wednesday November 19 2008
Creating an image from an array of data is an easy task, but to create a byte-array of data from an image is a little more complicated.
To create a byte-array of data from an image, we can use the getRGB(..) method in the image class in MIDP 2.0.
From the getRGB method we get an int-array of data containing all the ARGB values of each pixel in the image.
Integers in java are four bytes, so we need to split each int value into four byte values.
To mask out each of the bytes in the int we
Published at: 12:11 am - Tuesday November 18 2008
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import java.io.*;
public class httpconnection extends MIDlet implements CommandListener {
private Command exit, start;
private Display display;
private Form form;
public httpconnection ()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.EXIT, 1);
start = new Command("Start", Command.EXIT, 1);
form = new Form("Http Connection")
Published at: 12:11 am - Tuesday November 18 2008
This J2ME sample program shows how to how to make a SOCKET Connection from a J2ME Phone.
Many a times there is a need to connect theto a backend HTTP server from the J2ME application. This free J2ME sample program for example shows how to make a SOCKET connection from the phone to port 80 of http://www.java-samples.com website and retrieve the contents of index.htm file.
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import java
Published at: 08:11 am - Monday November 17 2008
This J2ME sample program shows how to CHANGE THE FONT SIZE and CHANGE COLOR.
Having worked with many different J2ME devices, I have come across many phones with small displays or small defaul fonts and sizes. However in real time usage, most of the times the customer needs a bigger font size. This sample J2ME code shows how to increase or change the font size according to our requirement.
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.io.*;
import
Published at: 02:11 am - Friday November 14 2008
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
public class BackgroundProcessing extends MIDlet
implements CommandListener {
private Display display;
private Form form;
private Command exit;
private Command start;
public BackgroundProcessing() {
display = Display.getDisplay(this);
form = new Form("Background Processing");
exit = new Command("Exit",