devxlogo

Managing the Form Flow in J2ME

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);			}}
See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist