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: 31
Registered: ‎08-26-2011
My Device: Torch 9810
My Carrier: AT&T

Re: New line stops display in multi-line text box

Ok, I went back to the original code from http://supportforums.blackberry.com/t5/Java-Development/TextBoxField-revisited/ta-p/548410 and just added my methods (see below).

 

package uid.rim.uidchecker;

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.container.VerticalFieldManager;

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

    private VerticalFieldManager vfm = new VerticalFieldManager(VERTICAL_SCROLL | VERTICAL_SCROLLBAR | USE_ALL_WIDTH | USE_ALL_HEIGHT);
    private EditField editField = new EditField("", "", EditField.DEFAULT_MAXCHARS, FOCUSABLE);

    TextBoxField(int width, int height, long style) {
        super(style | NO_VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL);
	managerWidth = width;
	managerHeight = height;
		
	add(vfm);
	vfm.add(editField);
    }

    TextBoxField(int width, int height) {
        this(width, height, 0L);
    }
		
    public String getText() {
	return editField.getText();
    }

    public int getPreferredWidth() {
        return managerWidth;
    }

    public int getPreferredHeight() {
        return managerHeight;
    }
    
    public void setFocus() {
   	 	editField.setFocus();
    }
    
    public void setText(String value) {
    	 editField.setText( value );
         editField.setCursorPosition( editField.getText().length() );
    }
    
    public void writeLine(String value) {
    	editField.setText( editField.getText() + value + "\n" );
    }
		
    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);
    }
}

 

 Now the left and right borders do not appear and the original problem remains.

 

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

Re: New line stops display in multi-line text box

Well, you'll need to debug the problem - I don't see what's wrong. As I've suggested, at least report exceptions. And try to make the debugger work for you - it is an invaluable tool sometimes.

----------------------------------------------------------
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: 31
Registered: ‎08-26-2011
My Device: Torch 9810
My Carrier: AT&T

Re: New line stops display in multi-line text box

It really looks to me like the new lines are somehow being ignored after the scan.  I have put a question to the vendor of the barcode library about this.