Home | Русский

Java – Applet

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); }/
Posted in: J2SE by admin No Comments , ,

J2ME – Images, Tickers and Gauges

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
Posted in: J2ME by admin 1 Comment , , , ,

J2ME – Form

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
Posted in: J2ME by admin No Comments , ,

J2ME – TextBox

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),
Posted in: J2ME by admin No Comments , ,

Convert ARGB to RGB in J2ME

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
Posted in: J2ME by admin No Comments , ,

J2ME – Http Connection

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")
Posted in: J2ME by admin No Comments , ,

J2ME – SOCKET connection

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
Posted in: J2ME by admin 1 Comment , ,

J2ME Program – change font size and color

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
Posted in: J2ME by admin No Comments , ,

Thread – Background Processing

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",
Posted in: J2ME by admin No Comments ,