Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified

Display Height and Width values when starting app in Landscape mode

Hi All,


Display API gives proper values when we have not forced any orientation*.   


* Conditions Apply Smiley Happy


Observation is, I was trying to get Device Width and Height even before pushing a Screen in Main event dispatcher


public static void main(String[] args) {
                Main app = new Main();


public Main() {
         System.out.println("============ Device width " + Display.getWidth());
         System.out.println("============ Device height " + Display.getHeight());
         UiApplication.getUiApplication().pushScreen(new TestScreen());

 Here when I have 9810 in landcape mode, then opening this test app this is printing Width = 640 and Height = 480.


In side Test Screen i have a button where I am displaying Width Height in Dialog


ButtonField buttonField = new ButtonField("Check Dimensions") {
    protected boolean navigationClick(int status, int time) {
        Dialog.alert("Display Width " + Display.getWidth()		+ " --Display Height " + Display.getHeight());
         return true;

 Here it it showing Width = 480, Height = 640.


I was thinking of getting these values before pushing screen and then doing some calculations based on that. But It seems app is not applying immediate force Portrait mode and hence displaying different values than displayed in Screen alert.


I think some of us here must be doing calculations based on Screen Width and Height. Anyone faced similar issues?