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
Trusted Contributor
Posts: 108
Registered: ‎09-03-2010
My Device: Not Specified
My Carrier: Developer
Accepted Solution

How could get the text box

hi

 

    I want to use a text box how could i get it? in edit field or basic edit field all are just displays as a line, but i need it as a box

 

Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: How could get the text box

do you want to have  a rich text field or you want to have borders around the textfield so that it looks like an enclosed box a depiction shown below

 

+-----------------+

|                         |

+-----------------+

Highlighted
Trusted Contributor
Posts: 108
Registered: ‎09-03-2010
My Device: Not Specified
My Carrier: Developer

Re: How could get the text box

No i want to display a text box as like you drawn and inside the text box i will give some label name and i want the user to enter inputs.

 

Now i have tried out for Basiceditfield, editfield, textfield, autocompletefield, autotext field but none displays like a box.

 

Can you plz help me?

Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: How could get the text box

Try this,

 

        BasicEditField txtuser = new BasicEditField("", "", 28, BasicEditField.FILTER_EMAIL)
        {            
            private int iRectX = getFont().getAdvance(getLabel());
            private int iRectWidth = Display.getWidth() - iRectX - 2;

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

            public int getPreferredHeight() 
            {
                return 30;
            }

            public void layout(int width, int height) 
            {
                super.layout(width, getPreferredHeight());
                setExtent(width, getPreferredHeight());
            }
            
            public void paint(Graphics g)   
            {
                g.setColor(0x000000);
                g.drawRect(iRectX, 0, 248, 20);
                super.paint(g);
            }
        };

 IT looks like what you want.

------------------------------------------------------------------------------------

Press Kudo to say thank to developer.
Also Press the Accept as solution Button when u got the Solution.

 

Developer
Posts: 374
Registered: ‎04-07-2010
My Device: Bold 9000
My Carrier: Airtel

Re: How could get the text box

If you are looking for the box around your Field, to make it appear like a text box on web...

use this:

 

 

Border b = BorderFactory.createSimpleBorder(new XYEdges(1,1,1,1));
BasicEditField B1 = new BasicEditField("", "", 10, BasicEditField.FIELD_LEFT |  BasicEditField.FILTER_NUMERIC);
B1.setBorder(b);

In this you create a Border and apply it to the BasicEditField... Go through these classes in API Reference for more Info.

 

Press the Like button (Thumb up) on the left side to thank and
please mark the Thread as solved if its solved...
K.S
Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: How could get the text box

you can use any of the following way:

 

1)

 

EditField myedit = new EditField()
{
  paint(Graphics graphics)
   {
       graphics.drawRect(x, y, width, height); //all 4 parameters are numeric or integer // x,y indicate starting position //width and height of edit field } }

 

 

 

Plz make sure that in the width of rectangle must be equal to width of editfield so that the contents do not go beyond it

 

 

2) u can add an image of any textbox to edit field and provide it the look like u want :

 

 

//textbox is a name of bitmap image

myedit = new EditField(EditField.NO_NEWLINE)
{
  protected void paint(Graphics graphics) 
   {
    graphics.drawBitmap(0, 0, textbox.getWidth(), textbox.getHeight(), textbox, 0, 0);
    super.paint(graphics);
   }
};

 

 

 

 

Trusted Contributor
Posts: 108
Registered: ‎09-03-2010
My Device: Not Specified
My Carrier: Developer

Re: How could get the text box

Thank you nitin, it works!!

Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: How could get the text box

hey there may be many more ways

these 2 are just the 2 ways

 

may be it can help u!!!!

Trusted Contributor
Posts: 108
Registered: ‎09-03-2010
My Device: Not Specified
My Carrier: Developer

Re: How could get the text box

Thank you kush i have tried the same using the separatorField, it also works.

Trusted Contributor
Posts: 108
Registered: ‎09-03-2010
My Device: Not Specified
My Carrier: Developer

Re: How could get the text box

Swati all you guys insist me to draw a rectangle or border over the text field. drawing rectangle works fine.

 

Can you confirm me is there no default api to get text box??