在Blackberry中自动扩展文本框

时间:2012-12-12 07:48:18

标签: blackberry textbox blackberry-jde

我已经在我的应用程序中实现了自定义文本框,但它运行良好但现在客户端需要在键入类似(BBM聊天文本框)时自动扩展texbox。有没有办法覆盖defualt Editfield自动扩展。请建议我。

1 个答案:

答案 0 :(得分:2)

这可能会做你想要的;自动增加EditField的高度:

class MyEditField extends EditField
{
    public MyEditField (long style)
    {
        super (style);
        setBorder (BorderFactory.createSimpleBorder(new XYEdges (1, 1, 1, 1)));
    }

    public int getPreferredHeight()
    {
        return Font.getDefault.getHeight() * 3; //setting the height of edit field as 3 rows
    }

    public void layout (int width, int height)
    {
        super.layout (width, height);
        if (getExtent().height < getPreferredHeight())
            setExtent (width, getPreferredHeight());
    }
}