dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java
Expertise: Intermediate
Jun 21, 2005

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Managing the Form Flow in J2ME

To manage form flow, the first thing you need to do is create a singleton class with static methods. Next, you implement a stackable system in which to store any object. The showPrevious() method exposes objects' special data.

package tips.formstack;
import java.util.Stack;

public class FormFlow {

	private static Stack stack = new Stack();
	
	public static void addInstance(Object instance) {
		stack.push(instance);
	}

	public static Object getInstance() {
		return stack.pop();
	}
	
	public static void showPrevious() {
		((Showable)FormFlow.stack.pop()).show();
	}
}

/*
 * Design an interface to extract common functionality
 */

package tips.formstack;

public interface Showable {
	void show();
}

/*
 * Design a class that implements Showable
*/
package tips.formstack;

public class MyShowableObject implements Showable {

	int index;
	
	public MyShowableObject(int index){
		this.index = index;
	}
		
	public void show() {
		System.out.println("Showing "+index);		
	}
}
Alejandro Parodi
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date