Custom toolbar will not appear

I created the toolbar class and classes below the tool bar button, but when I add an instance of the toolbar to a screen it will not appear.  I noticed that the painting of the ToolBarButtonFields methods are not called so.  So clearly I am missing something, advice?

SerializableAttribute public class ToolBarField extends Manager
{
Vector leftJustifiedButtons = new Vector();
Vector rightJustifiedButtons = new Vector();
preferredHeight int = 40;
   
public ToolBarField()
{
Super (Manager.NON_FOCUSABLE);
this.setBackground (BackgroundFactory.createSolidBackground (Color.BLACK));
}
   
public int getPreferredHeight()
{
return preferredHeight;
}

' Public Sub addButton (button ToolBarButtonField, rightJustified boolean)
{
Super.Add (Button);
       
If (button.getPreferredHeight () > preferredHeight)
preferredHeight = button.getPreferredHeight ();
       
If (! rightJustified)
{
leftJustifiedButtons.addElement (button);
}
on the other
{
rightJustifiedButtons.addElement (button);
}
}
   
public int getPreferredWidth()
{
East int = Display.getOrientation ();
If (Orient is Display.ORIENTATION_LANDSCAPE)
{
Return Display.getHeight ();
}
on the other
{
Return Display.getWidth ();
}
}
   
protected void sublayout (int maxWidth, maxHeight int)
{
buttonHeight int = getPreferredHeight();
buttonWidth int = 48;
int button = rightJustifiedButtons.size () + leftJustifiedButtons.size ();
       
If (buttons > 0)
{
buttonWidth = getPreferredWidth () / buttons;
}
       
Enumeration iter = rightJustifiedButtons.elements ();
int curX = maxWidth;
       
If (maxHeight > Display.getHeight ())
maxHeight = Display.getHeight ();
       
int y = maxHeight - this.getPreferredHeight ();
       
While (iter.hasMoreElements ())
{
Button for a field (Field) = iter.nextElement ();
this.layoutChild (button, buttonWidth, buttonHeight);
           
curX = curX - button.getWidth ();
this.setPositionChild (button, curX, y);
           
}
       
ITER = leftJustifiedButtons.elements ();
curX = 0;
       
While (iter.hasMoreElements ())
{
Button for a field (Field) = iter.nextElement ();
this.layoutChild (button, buttonWidth, buttonHeight);
                       
this.setPositionChild (button, curX, y);
curX = curX + button.getWidth ();
}
}
}

SerializableAttribute public class ToolBarButtonField extends ImageButtonField
{
private static final int WIDTH = 48;
private static final int HEIGHT = 36;
int prefWidth = WIDTH;
int prefHeight = HEIGHT;
   
public ToolBarButtonField (Bitmap focusImage, unFocusImage Bitmap)
{
Super (focusImage, unFocusImage, Field.HIGHLIGHT_FOCUS |) ButtonField.CONSUME_CLICK);
       
If (focusImage.getWidth)<>
prefWidth = focusImage.getWidth ();
       
If (focusImage.getHeight)< height)="">
prefHeight = focusImage.getHeight ();
}

public int getPreferredHeight()
{
Return prefHeight;
}

public int getPreferredWidth()
{
Return prefWidth;
}
}

SerializableAttribute public class ImageButtonField extends field
{
private Bitmap currentImage;
focusedImage private bitmap;
unFocusedImage private bitmap;

ImageButtonField (Bitmap, Bitmap unFocusImage, long style focusImage)
{
Super (style);
       
this.focusedImage = focusImage;
this.unFocusedImage = unFocusImage;
currentImage = focusedImage;
}
   
public int getPreferredHeight()
{
Return currentImage.getHeight () + 4;
}

public int getPreferredWidth()
{
Return currentImage.getWidth () + 4;
}
   
protected void onFocus (int direction)
{
currentImage = focusedImage;
Invalidate();
}

protected void onUnfocus()
{
currentImage = unFocusedImage;
Invalidate();
}
   
protected void drawFocus (graphics graphics, boolean on)
{
Do nothing
}
   
protected void layout (int width, int height)
{
setExtent (Math.min (width, getPreferredWidth()),
Math.min (height, getPreferredHeight()));
}

protected void paint (Graphics graphics)
{
graphics.setColor (Color.BLACK);
graphics.fillRect (0, 0, getWidth(), getHeight());
graphics.drawBitmap (0, 0, getWidth(), getHeight(), currentImage, 0, 0);
}
       
/**
* Substituted so that the Dispatch of the event thread can catch this event
* instead of having taken here...
* @see net.rim.device.api.ui.Field #navigationClick (int, int)
*/
protected boolean navigationClick (int status, int time)
{
fieldChangeNotify (1);
Returns true;
}
}

I assume that you add an instance of the ToolBarField Manager on your screen?

This bit would have to debug both.  For example, to delete your sublayout, extend FlowManager, add a normal button and see if it appears.

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for

  • Question on the slots of RAM on Satellite P200

    How to increase the ram to 2 GB (1 GB + 1 GB) to 4 GB?Satellite P200 has 4 slots and I add ram 1 gb + 1 gb for the unused slots, or only 2 slots and I need to replace the ram of 1 gb + 1 gb to 2 gb + 2 gb?

  • The pens for HP ENVY x 360 m6 convertible range

    I need help trying to find a pen that would work for the HP ENVY x 360 m6 cabriolet.   It's a recent purchase, and I chose the portable 2 in 1 for versatility of use it as tool for teaching (writing notes in a single note).  Any suggestion would be a

  • MSC vs MTP

    If this is not the case, using music services or download music, but only put records complete artist of mp3 files on music video, is it better to use the MSC? That would help solve the familiar tagging problem I see displayed and have met emyself? M

  • I can't open attachments to emails.

    I can't open attachments to emails.   I get the message "Required registry information is missing and this application cannot run.  Please return to the settings and correct the problem.  The program to open the attachments is broken and needs to be

  • I accidentally deleted the SwSetup folder...

    What it this folder contain? Was it something important? If so where can I download it?