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
ahmadahmad
Posts: 404
Registered: ‎05-31-2011
My Device: curve

set field focused by default

hi, how can i set a field focus by default by starting of a screen, example :

ButtonField b1, b2, b3;

b1 =  new ButtonField("b1");

b2 =  new ButtonField("b2");

b3 =  new ButtonField("b3");

add(b1);

add(b2);

add(b2);

in this example the b1 is set focus by default, but i want the button b2 to be focus as first without changing the drawing ordre of buttons?

Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: set field focused by default

This looks wrong:

 

add(b2);

add(b2);

 

assuming you correct that, then after that add

 

b2.setFocus();

Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: set field focused by default

Actually, b2.setFocus() should be invoked in your manager's onDisplay() (probably wrapped in invokeLater - I know I'm a little too paranoid about that, but using it prevents many strange glitches).

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!