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
Contributor
Posts: 28
Registered: ‎07-06-2011
My Device: 9800
My Carrier: blackberry developer trainee

TextBox creation

Hi all,

 

im creatin a textfield class and called two times for two fields.

but its working for one only

the next one is displaying for sometimes

here iam giving the code

pls give me a solution

 



public class TextBoxField extends VerticalFieldManager {


 //define some variables to be used  //in the class  

private int managerWidth;  

private int managerHeight;

 private EditField editField;  

 public TextBoxField(){

 super(Manager.NO_VERTICAL_SCROLL);

 }  

public TextBoxField(int width, int height) {

         managerWidth = width;

   managerHeight = height;      

 VerticalFieldManager vfm =new VerticalFieldManager(Manager.VERTICAL_SCROLL);


     editField = new EditField(){

       public void paint(Graphics g) {    

   getManager().invalidate();    

   super.paint(g);    

  // g.setBackgroundColor(Color.WHITE);  

   }          

 };    
  vfm.add(editField);   

   add(vfm);  

}  

public void paint(Graphics g) {

   g.drawRect(0, 0, getWidth(), getHeight());

 g.setColor(Color.BLACK);  

super.paint(g);  

}

public void sublayout(int width, int height) {

   super.sublayout(managerWidth, managerHeight);  

  setExtent(managerWidth,managerHeight);  

 //  Font myFont = Font.getDefault().derive(Font.EMBOSSED_EFFECT, 7, Ui.UNITS_pt);

}   p

ublic String getText() {

   return editField.getText();  

}  

public void setText(String text) {  

editField.setText(text);

 }}




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

Re: TextBox creation

You are using a very old and bad code of TextBoxField. Take a look at its replacement:

TextBoxField revisited

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 28
Registered: ‎07-06-2011
My Device: 9800
My Carrier: blackberry developer trainee

Re: TextBox creation

Hi,

that one is working and displaying two fields according to my code

 

 final TextBoxField numbr = new TextBoxField(300, 40);  

 final TextBoxField msg = new TextBoxField(300, 150);

 

But i cant write anything in the number field

can you help me?

Contributor
Posts: 28
Registered: ‎07-06-2011
My Device: 9800
My Carrier: blackberry developer trainee

Re: TextBox creation

When I am scrolling that one only the letters which i type are displaying that also only in the message field

Contributor
Posts: 28
Registered: ‎07-06-2011
My Device: 9800
My Carrier: blackberry developer trainee

TextBox Background

How Can I give white background to the textbox?

now its giving the background of my backround image?

can anybody help pls?????

Contributor
Posts: 24
Registered: ‎08-04-2010
My Device: Not Specified

Re: TextBox Background

You can use setBackground() method to set the background color for the Textbox.

 

Simple implementation would be:

 

EditField textbox = new EditField();
textbox.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));

 

Regards,

Suhas