Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6552893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:30:56+00:00 2026-05-25T12:30:56+00:00

I have created a very basic custom layout to set out a menu made

  • 0

I have created a very basic custom layout to set out a menu made up of ButtonFields.

To position them vertically, i split the screen into 6 and then put them at divides 2,3,4 and 5 as is shown in the code.

So for the emulator, the Torch, a Height of 480 would see buttons at 160,240,320 and 400.

However, when I check them, they are all 24 pixels below this, and there seems no obvious reason unless this is just a typical convention I have missed!

package Test;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.container.VerticalFieldManager;

class MenuLayoutManager extends VerticalFieldManager{

public MenuLayoutManager()
{
    super();
}

public int getPreferredWidth()
{
    int preferredWidth = Display.getWidth();
    return preferredWidth;
}

protected void sublayout(int inMaxWidth, int inMaxHeight)
{
int xCentre = Display.getWidth()/2;
int yGap = Display.getHeight() / 6;
int xPos = 0;
int yPos = yGap * 2;
int fieldNo = this.getFieldCount();

for(int index = 0; index<fieldNo; index++)
{
Field aField = this.getField(index);
this.layoutChild(aField, inMaxWidth, inMaxHeight);
xPos = xCentre - (aField.getWidth() / 2);
this.setPositionChild(aField, xPos, yPos);
yPos += yGap;
}
this.setExtent(inMaxWidth, inMaxHeight);


}
}

——Entry point and button creation—-

package Test;


import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.container.MainScreen;

class MyScreen extends MainScreen
{
public MyScreen(){
super(MainScreen.NO_VERTICAL_SCROLL|MainScreen.NO_VERTICAL_SCROLLBAR);
this.initialize();
}

private void initialize()
{        
    // Set the displayed title of the screen


    this.setTitle(String.valueOf("Ben's Menu"));

    MenuLayoutManager mlm = new MenuLayoutManager();
    ButtonField Button1 = new ButtonField("New Game");
    ButtonField Button2 = new ButtonField("High Scores");
    ButtonField Button3 = new ButtonField("Instructions");
    ButtonField Button4 = new ButtonField("Exit");
    mlm.add(Button1);
    mlm.add(Button2);
    mlm.add(Button3);
    mlm.add(Button4);
    this.add(mlm); 


}



}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:30:56+00:00Added an answer on May 25, 2026 at 12:30 pm

    With a MainScreen, you don’t get the full display height allocated to the screen contents. (At a minimum, IIRC, there’s the title and a separator.) Try using a FullScreen instead and see what happens.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a very basic database schema and have created a dbml from it.
I am very new to Installshield 2010. I have created a basic MSI setup
I have created a very basic service operation that needs to write content to
I have a very basic Visual Basic Program that I created in Visual Studio
I have created a very basic Rails 3.1 app, deployed to a box that
I want to ask very very basic question related to Mondrian. I have created
I have created a very simple sharepoint timer job. All i want it to
I am using SQL Server 2008 Enterprise. I have created a very simple test
I have created a custom dialog for Visual Studio Setup Project using the steps
I have just created a mid-sized web-application using Java, a custom MVC framework, javascript.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.