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

Posts: 263
Registered: ‎10-27-2010
My Device: 8520
Accepted Solution

Editfield + BitmapField in a horizontalfield manager

[ Edited ]



 I am using below code to show an Edit field and Bitmap in a horizontal field manager but i am getting illegal state exception..

 If i add BitmapField first and then edit field it's working fine but i need Editifield first and then BitmapField

here below is my code....

  Bitmap bg = Bitmap.getBitmapResource("twenty.png");
  locations = new BitmapField(bg,bg,"Locations");
  EditField table=new EditField("Ticket No : ","",5,EditField.FILTER_NUMERIC)
                private int iRectX = getFont().getAdvance(getLabel());
                private int iRectWidth = Display.getWidth() - iRectX - 4;
                public void paint(Graphics g)
                            g.drawRect(iRectX, 0, 170, 18);

  HorizontalFieldManager hfm=new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);

 I already tried by taking two horizontal fields to add edit field in one and image in another manager and added these two managers into vertical field but no luck..


 I tried table layout also..

Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Editfield + BitmapField in a horizontalfield manager

editfields use all available width.
you can overwrite getPreferredWidth or use a custom layout:
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
Posts: 263
Registered: ‎10-27-2010
My Device: 8520

Re: Editfield + BitmapField in a horizontalfield manager

By using below code my issue is solved...


public int getPreferredWidth() {
                    return Display.getWidth() ;

protected void layout(int width, int height) {
    width = Math.min(getPreferredWidth(), width);
    super.layout(width-85, height);


Thanks simon for your reply....