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
Regular Contributor
Posts: 92
Registered: ‎03-09-2013
My Device: bold 9800
My Carrier: blackberry

Non Edit able Text In Text Box

Hello every One, I am developing an application for Blackberry 9800 Torch mobile and my native language in JAVA. I am using my own Custom TextBox which is working fine, but i want to make it non edit able. I have used EditField.NonEditable as well as boolean Char key method but it is still makes an editable effect..I just want to show some text inside TextBox,but it should be non editable..

 

public class TextBox extends Manager
{
int managerWidth;
int managerHeight;


private EditField editField = new EditField("abcd@edeed.com.ed, "", EditField.DEFAULT_MAXCHARS, FOCUSABLE|EditField.NO_EDIT_MODE_INPUT);

 

TextBox (int width, int height, long style) {
super(style | NO_VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL);
managerWidth = width;
managerHeight = height;

add(vfm);
vfm.add(editField);
}

TextBox (int width, int height) {
this(width, height, 0L);
}
protected boolean keyChar(char key, int status, int time)
{
return true;
}
public String getText() {
return editField.getText();
}

public int getPreferredWidth() {
return managerWidth;
}

public int getPreferredHeight() {
return managerHeight;
}

protected void sublayout(int w, int h) {
if (managerWidth == 0) {
managerWidth = w;
}
if (managerHeight == 0) {
managerHeight = h;
}
int actWidth = Math.min(managerWidth, w);
int actHeight = Math.min(managerHeight, h);
layoutChild(vfm, actWidth - 2, actHeight - 2); // Leave room for border
setPositionChild(vfm, 1, 1); // again, careful not to stomp over the border
setExtent(actWidth, actHeight);
}

protected void paint(Graphics g) {
super.paint(g);
int prevColor = g.getColor();
g.setColor(Color.BLACK);
g.drawRect(0, 0, getWidth(), getHeight()); // draws border
g.setColor(prevColor);
}
}

 

abcd@edeed.com.ed is non editable, but after this i can make an input...But i just want to make whole Text Box non editable...Plx help me out there...

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Non Edit able Text In Text Box

I see you have used arkadyz's example TextBox from here:

http://supportforums.blackberry.com/t5/Java-Development/TextBoxField-revisited/ta-p/548410

 

It appears you have not cut and pasted the code completely - you are missing the vfm definition. 

 

Can you explain the effect you are trying to achieve.  nonEditable means different things to different people.

 

In you were looking for a standard Blackberry like effect, then setting the editField as non Editable should do that.

 

You can achieve this effect simply by adding the lines:

editField.setEditable(false);

 

after

add(vfm);

 

Alternatively, if you actually do not want the text to be focusable, then set NON_FOCUSABLE when constructing the editField. 

 

If neither of these options achieves the effect you want, then please describe that effect.