BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 07-20-2007, 03:29 PM   #1 (permalink)
Thumbs Must Hurt
Join Date: Feb 2007
Model: 8100
Carrier: T-Mobile
Posts: 54
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Focus problem! I'm going out of my mind!!!

Please Login to Remove!

Hi all,

This is a *seemingly* simple example of something I should be able to do.
I have a HorizontalFieldManager that contains a focusable, NullField so that I can utilize the onFocus() and onUnfocus() methods of the HorizontalFieldManager.
When you cursor into the HorizontalFieldManager, the onFocus() method adds two ButtonFields to itself, then sets its focus to the first ButtonField.
The focus IS on the first button, however, the button isn't "lit up" with the blue color that buttons normally are. If I move the focus to the 2nd button, then back to the 1st button, the button gets the correct decoration.
Any ideas anyone ????

Code Follows

Much appreciated

Matthew Wheaton

package com.wcs.blackberry;

import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.NullField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.HorizontalFieldManager;

public class Sandbox extends UiApplication
  public static void main(String[] args)
    Sandbox theApp = new Sandbox();

  public Sandbox()
    MainScreen screen = new SandboxScreen();

final class MyVFM extends HorizontalFieldManager
  protected void subpaint(Graphics g)

  protected void sublayout(int maxWidth, int maxHeight)
    int width = 200;
    super.sublayout(width, maxHeight);
    setExtent(width, getExtent().height);

  public int getPreferredWidth()
    return 200;

  protected void onFocus(int aDirection)
    ButtonField bf = new ButtonField("Button One");    
    ButtonField bf1 = new ButtonField("Button Two");    

  protected void onUnfocus()

final class SandboxScreen extends MainScreen
  public SandboxScreen()
    super(MainScreen.DEFAULT_MENU | MainScreen.DEFAULT_CLOSE);

    MyVFM vfm = new MyVFM();
    vfm.add(new LabelField("ABC"));
    vfm.add(new NullField(Field.FOCUSABLE));

    add(new EditField("", "Field One", 50, Field.EDITABLE));
    add(new EditField("", "Field Two", 50, Field.EDITABLE));

  public boolean onClose()
    return true;

  public boolean keyChar(char key, int status, int time)
    switch (key)
      case Characters.ESCAPE:
        return true;
    return super.keyChar(key, status, time);

Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Onset T-VER-8053-800, Veris Kilowatt Hour Transducer 3-Phase, 800 Amp Sensor
Onset T-VER-8053-800, Veris Kilowatt Hour Transducer 3-Phase, 800 Amp Sensor pictureOnset T-WNB-3Y-208, WattNode 208/240 VAC Transducer Sensor
Onset T-WNB-3Y-208, WattNode 208/240 VAC  Transducer Sensor pictureOnset T-VER-H970-200, Split-Core 200A DC Transducer
Onset T-VER-H970-200, Split-Core 200A DC Transducer pictureOnset T-VER-PXU-X, Differential Air Pressure Transducer Sensor
Onset T-VER-PXU-X, Differential Air Pressure Transducer Sensor pictureOnset T-WNB-3Y-208-P, WattNode 208-240VAC Transducer Sensor
Onset T-WNB-3Y-208-P, WattNode 208-240VAC Transducer Sensor picture

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.