Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

J2ME - Alert Bloccante

// description of your code here

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

public class MessageBox extends Alert implements CommandListener
{
	protected Chattando midlet;
	
	private boolean isReady = false;
	
	private Displayable dspBACK;
	
	public MessageBox(String title, String text, AlertType type, Chattando midlet)
	{
		super(title, text, null, type);
		
		this.midlet = midlet;
		
		this.setCommandListener(this);
		this.setTimeout(Alert.FOREVER);
		
		// Display Precedente
		dspBACK = midlet.getDisplay().getCurrent();
		
		// Mostra l'alert
		midlet.getDisplay().setCurrent(this);
		
		// Attendi la conferma di chiusura
		waitForDone();
		
		// Visualizza il precedente Display
		midlet.getDisplay().setCurrent(dspBACK);
	}
	
	private void waitForDone()
	{
		try
		{
			while(!isReady)
			{
				synchronized(this)
				{
					this.wait();
					
				}
			}
		}
		catch(Exception error)
		{
			
		}
	}

	public void commandAction(Command cmd, Displayable dsp)
	{
		if(cmd == Alert.DISMISS_COMMAND)
		{
			isReady = true;
			
			synchronized(this)
			{
				this.notify();
			}			
		}
	}
}

Displaying message or alert

from appuifw import note

message = u"All's well"    # must be unicode , using u""
note(message, 'info')     # 'info' or 'error' or 'conf'

# info = information message box
# error = error message box
# conf = confirm message box

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS