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
mbasheerk
Posts: 326
Registered: ‎02-02-2009
My Device: Not Specified

Re: change text of LabelField

what i have to code inside  onfocus() and ouunfocus() methods

i cant use setColor() because labelfield does not contains it

please give me hints

Please use plain text.
Developer
simon_hain
Posts: 16,199
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: change text of LabelField

extend the field. implement an int value for the color you want to have. in onFocus set the value to a color, in onUnfocus set the value to another color. In paint you call setColor with the int value.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
mbasheerk
Posts: 326
Registered: ‎02-02-2009
My Device: Not Specified

Re: change text of LabelField

link = new LabelField(xLabel, FOCUSABLE){
            int color = Color.BLUE;
            protected boolean navigationClick(int status, int time){
                UiApplication.getUiApplication().pushScreen(new screen());
                return true;
            }
            protected void paint(Graphics graphics){
                graphics.setFont(Font.getDefault().derive(Font.PLAIN | Font.UNDERLINED,8,Ui.UNITS_pt));
                graphics.setColor(color);
                graphics.drawText(xLabel,0,0);
            }
            protected void onFocus(int direction){
                color = Color.WHITE;
            }
            protected void onUnfocus(){
                color = Color.BLUE;
               
            }
 };

first time link will be blue, after getting focus it become white. but afterlossing focus it is not turnig to blue it still white so cant see the link

what i have make change in this code

Please use plain text.
Developer
bikas
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: change text of LabelField

Add invalidate in onFocus() and onUnfocus() method.

protected void onFocus(int direction) { color = Color.WHITE; invalidate(); } protected void onUnfocus() { color = Color.BLUE; invalidate(); }

 

Regards

Bikas

 

Please use plain text.