Welcome!

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

Reply
Developer
rakesh86shankar
Posts: 1,003
Registered: ‎05-22-2009
My Device: Not Specified
Accepted Solution

Doubts in Screen Orientation

Hi guys,i am developing my component.In it i am adding the LabelField which displays the Screen width,and when i change the orientation,the LabelField does not replace the labelfield's old width,But can make modifications to the things that are done in paint while screen orientation.

How to change it.

 

this is code

 

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import net.rim.device.api.ui.component.LabelField;

/**
 *
 * @author rakesh_2
 */
public class Component extends Manager 
{
    LabelField ld;
    int val;
    String s,s1;
    Font ft,temp;
    Component()
    {
        super(Manager.FOCUSABLE);
        chk();
        ld=new LabelField(s);
       
        
        this.add(ld);
        
    }
    
    protected void sublayout(int arg0, int arg1) 
    {
        chk();
        
        Field ff=this.getField(0);
        this.setPositionChild(ff, 5, 5);
        this.layoutChild(ff,Display.getWidth(), Display.getHeight()/2);
        this.setExtent(Display.getWidth(), Display.getHeight()/2);
        
    }
    public void chk()
    {
        val=Display.getWidth();
       
        s=String.valueOf(val);
        s1=s;
    }
    public void paint(Graphics g)
    {
        g.drawText(s, 15, 15);
        super.paint(g);
    }
    public void paintBackground(Graphics g)
    {
        g.setBackgroundColor(Color.LEMONCHIFFON);
        g.clear();
    }   
            
}

 

 

So how to change the LabelField width,on screen orientation?

 

 

Regards

Rakesh Shankar.P

Please use plain text.
Administrator
MSohm
Posts: 14,554
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Doubts in Screen Orientation

What BlackBerry Smartphone model and BlackBerry device software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

 

Can you elaborate on what you are seeing?  Is paint not being called when you change the orientation or is there an issue getting the proper display size after the rotation?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
rakesh86shankar
Posts: 1,003
Registered: ‎05-22-2009
My Device: Not Specified

Re: Doubts in Screen Orientation

Hello Sir,thanks for you reply and sorry for my late reply.

 

I am developing an application and when i can change the screen orientation,the width of Datefied is not changing,i should change when i change the orientation.

 

Whatever i do with paint it works well,but in case of fieldds such as LabelField or dateField,etc it does not change based on orientation.

 

 

 

For eg I displayed the labelfield with its value as Display.getWidth(),when i change the orientation,it displays the same value of old screen value.it does not change value based on screeen orientation,

Not only this,in case if i have to increase the font based on Screen Orientation.

 

Is it possible Sir?

 

 

 

Regards

 

Rakesh Shankar.P

Please use plain text.
Administrator
MSohm
Posts: 14,554
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Doubts in Screen Orientation

The values returned from Display.getWidth and Display.getHeight should change after rotating the screen.  Rotating the screen may or may not change the size of a field.  For example a field may not take up the width of the screen in portrait or landscape mode, so you won't see any changes.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
rakesh86shankar
Posts: 1,003
Registered: ‎05-22-2009
My Device: Not Specified

Re: Doubts in Screen Orientation

Thanks Mark,I got it.

Please use plain text.