Archive for the 'midlet' Category

Simple demo of using timers

import java.util.*;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;
public class TimerMidlet extends MIDlet implements CommandListener{ private Display display; private Form form; private Command exit; private Command stop; private Timer timer; private RunTimerTask tt; […]

A utility of startTimer

// Starts a timer to run a simple taskprivate void startTimer( ) {
// Create a task to be run task = new TimerTask( ) {
private boolean isPaused; private int count;
[…]

A MIDlet with Hello text and an Exit command

/* * * Copyright (c) 2000 Sun Microsystems, Inc. All Rights Reserved. * * This software is the confidential and proprietary information of Sun * Microsystems, Inc. (”Confidential Information”). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered […]

Sort mixed records in RMS

/*J2ME: The Complete Reference
James Keogh
Publisher: McGraw-Hill
ISBN 0072227109
*///jad file (please verify the jar size)/*MIDlet-Name: SortMixedRecordDataTypeExampleMIDlet-Version: 1.0MIDlet-Vendor: MyCompanyMIDlet-Jar-URL: SortMixedRecordDataTypeExample.jarMIDlet-1: SortMixedRecordDataTypeExample, , SortMixedRecordDataTypeExampleMicroEdition-Configuration: CLDC-1.0MicroEdition-Profile: MIDP-1.0MIDlet-JAR-SIZE: 100
*/
import javax.microedition.rms.*;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import java.io.*;
public class SortMixedRecordDataTypeExample extends MIDlet implements CommandListener{ private Display […]

How to search a simple record in RMS

/*J2ME: The Complete Reference
James Keogh
Publisher: McGraw-Hill
ISBN 0072227109
*/
// jad file (Please verify the jar size first)/*MIDlet-Name: SearchExampleMIDlet-Version: 1.0MIDlet-Vendor: MyCompanyMIDlet-Jar-URL: SearchExample.jarMIDlet-1: SearchExample, , SearchExampleMicroEdition-Configuration: CLDC-1.0MicroEdition-Profile: MIDP-1.0MIDlet-JAR-SIZE: 100
*/import javax.microedition.rms.*;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import java.io.*;
public class SearchExample extends MIDlet implements CommandListener{ private Display display; private Alert alert; private Form form; private Command exit; private […]

How to sort simple records in RMS

/*J2ME: The Complete Reference
James Keogh
Publisher: McGraw-Hill
ISBN 0072227109
*///jad file (please verify the jar size)/*MIDlet-Name: SortExampleMIDlet-Version: 1.0MIDlet-Vendor: MyCompanyMIDlet-Jar-URL: SortExample.jarMIDlet-1: SortExample, , SortExampleMicroEdition-Configuration: CLDC-1.0MicroEdition-Profile: MIDP-1.0MIDlet-JAR-SIZE: 100
*/import javax.microedition.rms.*;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import java.io.*;
public class SortExample extends MIDlet implements CommandListener{ private Display display; private Alert alert; private Form form; private Command exit; private Command start; […]

An example of use of RMS for storing persistent data

import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.rms.*;import java.io.*;
public class RMSDemo extends MIDlet implements CommandListener {
private Display display; private RecordStore rs=null; private Command exit; private RecordEnumeration re; private int recordNO; Form frm; int index=0; […]

Download and view a PNG file

/*————————————————–* ViewPng.java** Download and view a png file** Example from the book: Core J2ME Technology* Copyright John W. Muchow http://www.CoreJ2ME.com* You may use/modify for any non-commercial purpose*————————————————-*/import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.io.*;import java.io.*;
public class ViewPng extends MIDlet implements CommandListener{ private Display display; private TextBox tbMain; private Form fmViewPng; […]

A sample of graphics - commands and event handling

This example implements the following features in one Midlet:
Implementing Pie Charts and Bar Charts How to use multiple choices How to use exclusive lists
/* * @(#)Sample.java 1.9 01/06/08 * Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved. */
import javax.microedition.midlet.*;import javax.microedition.lcdui.*;
/* * A quick sample of graphics, commands, and event handling. */public […]

Displaying images as thumbnails on J2ME devices

Images can be viewed as thumbnails on wireless devices. The method below creates thumbnails from images
private Image createThumbnail(Image image) { int sourceWidth = image.getWidth(); int sourceHeight = image.getHeight();
int thumbWidth = 64; int thumbHeight = -1;
if (thumbHeight == -1) […]