Display a ButtonField and a LabelField temporarily on the top and
bottom of the screen
-
Import the required classes and interfaces.
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.extension.container.*;
-
Create the application framework by extending the
UiApplication class. In
main(), create an instance of the new class and
invoke
enterEventDispatcher() to enable the application to
receive events. In the application constructor, invoke
pushScreen() to display the custom screen for the
application. The
EyelidFieldManagerDemoScreen class, described in
step 3, represents the custom screen.
public class EyelidFieldManagerDemo extends UiApplication
{
public static void main(String[] args)
{
EyelidFieldManagerDemo app = new EyelidFieldManagerDemo();
app.enterEventDispatcher();
}
public EyelidFieldManagerDemo()
{
pushScreen(new EyelidFieldManagerDemoScreen());
}
}
-
Create the framework for the custom screen by extending the
MainScreen class.
class EyelidFieldManagerDemoScreen extends MainScreen {
{
public EyelidFieldManagerDemoScreen()
{
}
}
-
In the screen constructor, invoke
setTitle() to specify the text that appears in the
title section of the screen.
setTitle("EyelidFieldManager Demo");
-
In the screen constructor, create an instance of the
EyelidFieldManager class.
EyelidFieldManager manager = new EyelidFieldManager();
-
In the screen constructor, invoke
EyelidFieldManager.addTop() to add a
LabelField object to the top manager of the
EyelidFieldManager.
manager.addTop(new LabelField("Hello World"));
-
In the screen constructor, create a
HorizontalFieldManager object. Invoke
HorizontalFieldManager.add() to add buttons to the
HorizontalFieldManager. Invoke
EyelidFieldManager.addBottom() to add the
HorizontalFieldManager to the bottom manager of the
EyelidFieldManager.
HorizontalFieldManager buttonPanel = new HorizontalFieldManager(Field.FIELD_HCENTER | Field.USE_ALL_WIDTH);
buttonPanel.add(new SimpleButton("Button 1"));
buttonPanel.add(new SimpleButton("Button 2"));
manager.addBottom(buttonPanel);
-
In the screen constructor, invoke
EyelidFieldManager.setEyelidDisplayTime() to
specify, in milliseconds, the period of inactivity that must elapse before the
pair of managers disappear.
manager.setEyelidDisplayTime(3000);
-
In the screen constructor, invoke
add() to add the
EyelidFieldManager to the screen.
add(manager);
Code sample: Displaying a ButtonField and a LabelField temporarily on
the top and bottom of the screen
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.extension.container.*;
public class EyelidFieldManagerDemo extends UiApplication
{
public static void main(String[] args)
{
EyelidFieldManagerDemo app = new EyelidFieldManagerDemo();
app.enterEventDispatcher();
}
public EyelidFieldManagerDemo()
{
pushScreen(new EyelidFieldManagerDemoScreen());
}
}
class EyelidFieldManagerDemoScreen extends MainScreen
{
public EyelidFieldManagerDemoScreen()
{
setTitle("EyelidFieldManager Demo");
EyelidFieldManager manager = new EyelidFieldManager();
manager.addTop(new LabelField("Hello World"));
HorizontalFieldManager buttonPanel = new HorizontalFieldManager(Field.FIELD_HCENTER | Field.USE_ALL_WIDTH);
buttonPanel.add(new ButtonField("Button 1"));
buttonPanel.add(new ButtonField("Button 2"));
manager.addBottom(buttonPanel);
manager.setEyelidDisplayTime(3000);
add(manager);
}
}
Was this information helpful? Send us your comments.