Academic Tutorials



English | French | Portugese | German | Italian
Home Advertise Payments Recommended Websites Interview Questions FAQs
News Source Codes E-Books Downloads Jobs Web Hosting
Chats

J2ME
Introduction to J2ME
J2ME Development Kit
Understanding the Process of MIDlet
The MIDlet Lifecycle
User Interface Architecture
Alert
List
Text Box
Form
Images, Tickers and Gauges
Handling User Commands
Working with the Low-Level API
J2ME Gaming API
A Very Short Primer on Game Building
Building a J2ME Game
Defining Game Characteristics
TiledLayer
Sprites and LayerManager
Managing Layers
Sprites and Detecting Collisions
Mobile Media API
Using Mobile Media API (MMAPI)
Streaming media over the network

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting
Network Sites


Images, Tickers and Gauges


Previoushome Next






Images, Tickers, and Gauges

Using images, tickers, and gauges as UI elements in MIDlets is quite straightforward.

A D V E R T I S E M E N T
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, an image, can be used with various UI elements, including a form, as we saw in the last section.

Since the ticker can be used with all displayable elements, it provides a handy way to display information about the current element on the screen. The Displayable class provides the method setTicker(Ticker ticker), and the ticker can itself be created using its constructor Ticker(String msg), with the message that you want the ticker to display. By using setString(String MSG), you can change this message, and this change is effected immediately. For example, the form used in the previous section can have its own ticker displayed by setting form.setTicker(new Ticker("Welcome to Vandalay Industries!!!")). This will result in a ticker across the top of the screen (in the Toolkit's emulator), while the user is filling out the form. This is shown in Figure 6.

Figure 6
Figure 6. Setting a Ticker on a Displayable

In the previous section, we saw an example of a gauge in a non-interactive mode. It was there to represent the progress of a form being filled out by the MIDlet user. A non-interactive gauge can be used to represent the progress of a certain task; for example, when the device may be trying to make a network connection or reading a datastore, or when the user is filling out a form. In the previous section, we created a gauge by specifying four values. The label ("Step 1 of 3"), the interactive mode (false), the maximum value (3) and the initial value (1). However, when you don't know how long a particular activity is going to take, you can use the value of INDEFINITE for the maximum value.

A non-interactive gauge that has an INDEFINITE maximum value acquires special meaning. (You cannot create an interactive gauge with an INDEFINITE maximum value.) This type of gauge can be in one of four states, and this is reflected by the initial value (which is also the current value of the gauge). These states are CONTINUOUS_IDLE, INCREMENTAL_IDLE, CONTINUOUS_RUNNING, and INCREMENTAL_UPDATING. Each state represents the best effort of the device to let the user know the current activity of the MIDlet, and you can use them to represent these states yourself. Listing 5 shows an example of using these non-interactive gauges, along with an example of an interactive gauge. Remember that a Gauge is a UI Item, and therefore, can only be displayed as part of a Form.

Package com.j2me.part2;

import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Gauge;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;

public class GaugeExample extends MIDlet {

	private Form form;
	private Gauge niIndefinate_CI;
	private Gauge niIndefinate_II;
	private Gauge niIndefinate_CR;
	private Gauge niIndefinate_IU;

	private Gauge interactive;

	public GaugeExample() {
		form = new Form("Gauge Examples");

		niIndefinate_CI =
		  new Gauge(
				"NI - Cont Idle",
				false,
				Gauge.INDEFINITE,
				Gauge.CONTINUOUS_IDLE);
		form.append(niIndefinate_CI);

		niIndefinate_II =
		  new Gauge(
				"NI - Inc Idle",
				false,
				Gauge.INDEFINITE,
				Gauge.INCREMENTAL_IDLE);
		form.append(niIndefinate_II);

		niIndefinate_CR =
		  new Gauge(
				"NI - Cont Run",
				false,
				Gauge.INDEFINITE,
				Gauge.CONTINUOUS_RUNNING);
		form.append(niIndefinate_CR);

		niIndefinate_IU =
		  new Gauge(
				"NI - Inc Upd",
				false,
				Gauge.INDEFINITE,
				Gauge.INCREMENTAL_UPDATING);
		form.append(niIndefinate_IU);

		interactive =
		  new Gauge(
				"Interactive ",
				true,
				10,
				0);
		form.append(interactive);

	}

	public void startApp() {
		Display display = Display.getDisplay(this);
		display.setCurrent(form);
	}

	public void pauseApp() {
	}

	public void destroyApp(boolean unconditional) {
	}
}

Listing 5. Using Gauges

Each mobile device will use its own set of images to represent these gauges. This will, in all probability, be different from the gauges that you will see if you run this listing in the Emulator supplied with the Toolkit.

You can also associate an image with an Alert and a Choice-based UI element. When an image is created, either by reading from a physical location or by making an image in-memory, it exists only in the off-screen memory. You should, therefore, be careful while using images, and restrict the size of images to the minimum possible to avoid filling the device's available memory.

The Image class provides several static methods to create or acquire images for use in MIDlets. An image that is created in-memory, by using the createImage(int width, int height) method, is mutable, which means that you can edit it. An image created this way initially has all of its pixels set to white, and you can acquire a graphics object on this image by using the method getGraphics() to modify the way it is rendered on screen. More about the Graphics object follows in the low-level API section.

To acquire an immutable image, you can use one of two methods: createImage(String imageName) or createImage(InputStream stream). The first method is used for looking up images from an associated packaged .jar file, while the second method is good for reading an image over a network. To create an immutable image from in-memory data, you can either use createImage(byte[] imageData, int imageOffset, int imageLength) or createImage(Image source). The first method allows you to form an image out of a byte array representation, while the second allows the creation of an image from an existing image.

Note that the MIDlet specification mandates support for the Portable Network Graphics format for images. Thus, all devices that support MIDlets will display a *.png image. These devices may support other formats, especially GIF and JPEG formats, but that is not a guarantee.

You have already seen an example of acquiring an image in the section on forms. In Listing 4, an image was wrapped up in an ImageItem class so that it could be displayed in a form. The image was kept in the res folder of the MIDlet for the Toolkit and the Emulator to find. The createImage(String imageName) method uses the Class.getResourceAsStream(String imageName) method to actually locate this image. The Toolkit takes care of packaging this image in the right folder when you create a ,jar file. In this case, this will be the top-level .jar folder. Make sure that whenever you reference images in your MIDlets that the images are kept in the right location. For example, if you want to keep all of your images for a MIDlet in an image folder in the final packaged .jar file, and not the top-level .jar folder, you will need to keep these images under an image folder under the res folder itself. To reference any of these images, you will need to ensure that you reference them via this images folder. For example: createImage("/images/duke.gif"); will reference the image duke.gif under the images folder.



Be the first one to comment on this page.




  J2ME eBooks

No eBooks on J2ME could be found as of now.

 
 J2ME FAQs
More Links » »
 
 J2ME Interview Questions
More Links » »
 
 J2ME Articles
More Links » »
 
 J2ME News
More Links » »
 
 J2ME Jobs
More Links » »

Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previoushome Next

Keywords: Images, Tickers and Gauges, j2me introduction, J2ME Tutorial, j2me tutorial netbeans, j2me background process, j2me development kit, J2ME tutorial pdf, history of J2ME, basic J2ME, syntax use in J2ME, J2ME training courses, J2ME download.

HTML Quizzes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizzes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizzes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizzes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizzes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizzes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building Quizzes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizzes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizzes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizzes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizzes
Oracle Quiz
MySQL Quiz
Operating System Quizzes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizzes
Testing Quiz
Firewalls Quiz
SAP Module Quizzes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizzes
Corba Quiz
Networking Quiz
Microsoft Office Quizzes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizzes
Financial Accounting Quiz
Managerial Accounting Quiz
Testimonials | Contact Us | Link to Us | Site Map
Copyright ? 2008. Academic Tutorials.com. All rights reserved Privacy Policies | About Us
Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | Discussions World | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Indian Free Ads | Jobs Assist | New Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Webhosting in India | Dedicated Server in India | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Testing Interview Questions | Tests World | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World | Important Websites
Copyright ? 2003-2024 Vyom Technosoft Pvt. Ltd., All Rights Reserved.