在 J2ME 中的 LWUIT 表中自定义创建单元格

发布于 2024-08-31 20:02:08 字数 116 浏览 3 评论 0原文

我正在尝试在 J2ME 应用程序中创建一个 LWUIT 表,其中一列中的所有单元格都属于特定类型,例如采用十进制输入的 TextField。

有人可以建议我实现这一目标,甚至是我可以采取的另一种方法吗?

I am trying to create a LWUIT Table in my J2ME application where all cells in one column are of a particular type e.g. TextField taking decimal input.

Could anyone please suggest of achieving this or even another approach I could take?

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

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

发布评论

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

评论(1

风向决定发型 2024-09-07 20:02:08

我找错了区域。

我没有使用 ListCellRenderer 而是扩展了 Table 对象并覆盖了 createCell 方法。

public class CustomTable extends Table{
    public CustomTable(TableModel model) {
        super(model);
    }
    protected Component createCell(Object value, int row, int column, boolean editable) {
        switch (column) {
            case QUANITY_COLUMN:
                // create custom cell and return
                ...
            default:
                return super.createCell(value, row, column, editable);
        }
    }

}

I was looking in the wrong area.

Instead of using ListCellRenderer I extended the Table object and overrode the createCell method.

public class CustomTable extends Table{
    public CustomTable(TableModel model) {
        super(model);
    }
    protected Component createCell(Object value, int row, int column, boolean editable) {
        switch (column) {
            case QUANITY_COLUMN:
                // create custom cell and return
                ...
            default:
                return super.createCell(value, row, column, editable);
        }
    }

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