EditFields 周围的边框 - Blackberry

发布于 2024-10-31 00:14:13 字数 967 浏览 5 评论 0原文

我正在尝试在两个文本框周围绘制边框,如果我单独保留主屏幕的背景颜色,则该边框有效。客户的规格要求采用蓝色背景的配色方案。当 EditFields 被绘制到屏幕上时,它们将显示为跨越屏幕的一个字段。有 2 个,因为每个都在应该有两个时获得焦点,否则一切正常。然后将两个 EditField 添加到 GridFieldManager 以控制布局。在此处输入图像描述

我正在对 EditField 进行子类化并添加每个 EXEditField 周围的边框,如下所示:

public class EXEditField extends EditField {

    ...


    private void init( MainScreen scrn ) {
                if ( this.hasVirtualKeyboard() )
                    this.vkbd = scrn.getVirtualKeyboard();

                this.setMaxSize( this.MAX_CHARS );

                this.setBorder( BorderFactory.createRoundedBorder(new XYEdges(0,0,0,0), Border.STYLE_SOLID) );
                this.setBackground( BackgroundFactory.createSolidBackground(Color.WHITE) );
                //this.setPadding( 3, 3, 3, 3 );
                //this.setMargin( 0, 3, 0, 3 );
            }

    ...

    } // end class

非常感谢任何帮助,因为没有太多好的 Blackberry 参考文档。

I am trying to draw a border around two text boxes, which works if I leave background colour of the main screen alone. The client's spec's call for a colour scheme with a blue background. When the EditFields are drawn to the screen, they appear as one field that spans the screen. There are 2 since each gets focus when it's supposed two and everything works otherwise. The two EditFields are then added to a GridFieldManager to control the layout.enter image description here

I am subclassing the EditFields and adding the border around each of the EXEditFields, like so:

public class EXEditField extends EditField {

    ...


    private void init( MainScreen scrn ) {
                if ( this.hasVirtualKeyboard() )
                    this.vkbd = scrn.getVirtualKeyboard();

                this.setMaxSize( this.MAX_CHARS );

                this.setBorder( BorderFactory.createRoundedBorder(new XYEdges(0,0,0,0), Border.STYLE_SOLID) );
                this.setBackground( BackgroundFactory.createSolidBackground(Color.WHITE) );
                //this.setPadding( 3, 3, 3, 3 );
                //this.setMargin( 0, 3, 0, 3 );
            }

    ...

    } // end class

Any help is greatly appreciated since there is not much in the way good Blackberry reference docs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小镇女孩 2024-11-07 00:14:13

好的,检查这个

它是一个开源库,提供一些自定义 BlackBerry 字段,包括带有自定义边框的 EditField。您应该能够修改代码以显示您想要的边框。

Ok, check this.

It is an open source library that provides some custom BlackBerry fields, including an EditField, with custom borders. You should be able to modify the code to display the borders you want.

我们只是彼此的过ke 2024-11-07 00:14:13

您可以尝试更改自定义 EditField 中的 PaintBackground 方法,尝试将此代码放入您的 EditField 类中:

    protected void paintBackground(Graphics graphics) {

        graphics.setColor(Color.BLACK);
        graphics.drawRect(0, 0, getWidth(), getHeight());

        graphics.setColor(Color.WHITE);
        graphics.fillRect(0, 0, getWidth(), getHeight());
    }

You might try changing the paintBackground method within your custom EditField, try putting this code into your EditField class:

    protected void paintBackground(Graphics graphics) {

        graphics.setColor(Color.BLACK);
        graphics.drawRect(0, 0, getWidth(), getHeight());

        graphics.setColor(Color.WHITE);
        graphics.fillRect(0, 0, getWidth(), getHeight());
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文