Code sample: Displaying a label at an absolute position on the screen

import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;

public class AbsoluteFieldManagerDemo extends UiApplication
{
    	public static void main(String[] args)
    	{
             AbsoluteFieldManagerDemo app = new AbsoluteFieldManagerDemo();
             app.enterEventDispatcher();
    	}
    
    	public AbsoluteFieldManagerDemo()
    	{
             pushScreen(new AbsoluteFieldManagerDemoScreen());
    	}
}

class AbsoluteFieldManagerDemoScreen extends MainScreen
{	
	    public AbsoluteFieldManagerDemoScreen()
	    {
             setTitle("AbsoluteFieldManager Demo");
             AbsoluteFieldManager manager = new AbsoluteFieldManager();
		
             int halfwayDown = Display.getHeight() / 2;

             manager.add(new LabelField("Hello world"), 2, halfwayDown);
             add(manager);
       }
}
Next topic: UI components

Was this information helpful? Send us your comments.