如何使用 LWUIT 1.4 设置边框标题?如何对奇数和成对的表格行进行着色?

发布于 2024-11-09 03:16:55 字数 478 浏览 0 评论 0原文

我使用 LWUIT 1.4

1)在我的表单中有一个基于 BoxLayout(Y 轴)的容器,有两个标签添加到该容器中,我想创建一个 titled 边框放置到容器,使其包围两个标签。我知道创建一个边框,但我不知道如何使用 LWUIT 1.4 为边框设置标题!那么如何使用 LWUIT 1.4 设置边框的标题呢?

2)在我的表单中,有一个基于 DefaultTableModel 类的表,其 getValueAt 方法是通过记录存储的枚举来实现的,并且我希望表的行根据行的索引进行着色:例如,当行索引是奇数,那么它的背景颜色应该是白色,如果行索引是对,那么它的背景颜色应该是灰色。如何实现这一目标?

3)为什么TableLayout.Constraint方法不起作用?我想让表的两列具有相同的大小,即每列的表总宽度的 50%,但是当我运行应用程序时,当其数据不相等时,第一列与第二列的大小不相等够长了!那么如何使列的大小相等呢?

确实非常感谢

I use LWUIT 1.4

1) In my Form there is a Container based on a BoxLayout ( Y axis ) , there are two Label's added to this container , and I want to create a titled Border to be placed into the container so it surrounds the two labels. I know to create a Border , but I do not know how to set a title to the Border with LWUIT 1.4 ! So how to set a title to a Border with LWUIT 1.4 ?

2) In my Form there is a Table based on the DefaultTableModel class whose getValueAt method is implemented with an enumeration of a recordstore , and I want that the rows of the Table are colored according to the index of the row : for example when the row index is odd then its background color should be white , and if the row index is pair then its background color should be gray. How to achieve that ?

3) Why do not the TableLayout.Constraint methods work ? I want to make two columns of a Table to have equal size , that is 50% of the Table total width for each column , but when I run the application then the first column is not equally sized with the second column when its data are not long enough ! So how to make the columns equally sized ?

Thank you very much indeed

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

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

发布评论

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

评论(2

十级心震 2024-11-16 03:16:56

1) 主干中有一个标题边框,但我认为它是在 1.4 中添加的。
您可以通过重写 Container PaintBorder 方法来绘制类似的东西(请注意,您将需要足够的组件填充才能使边框正确显示。这是来自 SVN 版本的代码,只需很少的更改即可工作(只需将 c 更改为此):

Font f=c.getStyle().getFont();
int titleW=f.stringWidth(borderTitle);
int topPad=c.getStyle().getPadding(Component.TOP);
int topY=y+(topPad-thickness)/2;
if (c.isRTL()) {
    g.fillRect(x+width-TITLE_MARGIN, topY, TITLE_MARGIN , thickness); //top (segment before the title)
    g.fillRect(x, topY, width-(TITLE_MARGIN +titleW+TITLE_SPACE*2), thickness); //top (segment after the title)
    g.drawString(borderTitle, x+width-(TITLE_MARGIN +titleW+TITLE_SPACE), y+(topPad-f.getHeight())/2);
} else {
    g.fillRect(x, topY, TITLE_MARGIN , thickness); //top (segment before the title)
    g.fillRect(x+TITLE_MARGIN +titleW+TITLE_SPACE*2, topY, width-(TITLE_MARGIN +titleW+TITLE_SPACE*2), thickness); //top (segment after the title)
    g.drawString(borderTitle, x+TITLE_MARGIN+TITLE_SPACE, y+(topPad-f.getHeight())/2);
}

g.fillRect(x, y+height-thickness, width, thickness); //bottom
g.fillRect(x, topY, thickness, height); //left
g.fillRect(x+width-thickness, topY, thickness, height); //right

2)派生表并重写方法:

protected Component createCell(Object value, int row, int column, boolean editable)

调用super.createCell()并将返回值的UIID适当设置为“OddRow”,“EvenRow”。在资源编辑器或主题中设置您喜欢的任何样式。

3)我不知道有这样的问题。如果当前 SVN 上发生这种情况,您应该在项目问题跟踪器中提交问题。

1) There is a titled border in the trunk but I think it was added in 1.4.
You can draw something like this by overriding the Container paintBorder method (notice you will need sufficient component padding for the border to appear properly. This is the code from the SVN version, should work with very little changes (just change c to this):

Font f=c.getStyle().getFont();
int titleW=f.stringWidth(borderTitle);
int topPad=c.getStyle().getPadding(Component.TOP);
int topY=y+(topPad-thickness)/2;
if (c.isRTL()) {
    g.fillRect(x+width-TITLE_MARGIN, topY, TITLE_MARGIN , thickness); //top (segment before the title)
    g.fillRect(x, topY, width-(TITLE_MARGIN +titleW+TITLE_SPACE*2), thickness); //top (segment after the title)
    g.drawString(borderTitle, x+width-(TITLE_MARGIN +titleW+TITLE_SPACE), y+(topPad-f.getHeight())/2);
} else {
    g.fillRect(x, topY, TITLE_MARGIN , thickness); //top (segment before the title)
    g.fillRect(x+TITLE_MARGIN +titleW+TITLE_SPACE*2, topY, width-(TITLE_MARGIN +titleW+TITLE_SPACE*2), thickness); //top (segment after the title)
    g.drawString(borderTitle, x+TITLE_MARGIN+TITLE_SPACE, y+(topPad-f.getHeight())/2);
}

g.fillRect(x, y+height-thickness, width, thickness); //bottom
g.fillRect(x, topY, thickness, height); //left
g.fillRect(x+width-thickness, topY, thickness, height); //right

2) Derive table and override the method:

protected Component createCell(Object value, int row, int column, boolean editable)

call super.createCell() and set the UIID of the returned value to "OddRow","EvenRow" appropriately. Style in the resource editor or theme to anything you like.

3) I'm not aware of such an issue. If this happens on the current SVN you should file an issue in the projects issue tracker.

晒暮凉 2024-11-16 03:16:56

我从您的博客网站下载了最新的资源编辑器,并定义了组件 TableCell 的背景和边框“选定”版本,但是当我单击最后一个列表格单元格时,额外的矩形始终在运行时显示!我尝试在组件 focusGained() 实现的方法中调用 tableName.repaint() ,因为我将其注册到 focuslistener ,但矩形并没有消失。
我创建了一个对话框来显示所选的行号,当我单击第三个软按钮时显示对话框时,矩形消失了!也许表格单元格失去了焦点!每当我开火时,我都会得到与以前相同的行号;所以不存在行号错误。那么我应该编写什么代码,或者应该在编辑器中编辑什么属性才能获得与显示对话框以使矩形消失相同的效果?

I downloaded the latest Resource Editor from your blog site , and I defined the background and border "selected" versions of the component TableCell , but the extra-rectangle is always shown in runtime when I click on a last column table cell ! I tried to call tableName.repaint() in the component focusGained() implemented method , because I registered it to a focuslistener , but the rectangle does not disappear.
I created a Dialog to show the selected row number and when the Dialog is shown when I click the third softbutton then the rectangle disappeared !!! Perhaps the focus is lost from the table cell !! And whenever I fire then I got the same row number as before ; so there is no row number error. So what code should I write , or what property should I edit in the Editor to get the same effect as of displaying the Dialog to make the rectangle disappear ?

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