0

[a] [b] [c]

flextable1.setWidget(0, 0, new Label("a"));
flexTable1.setWidget(0, 1, new Label("b"));
flexTable1.setWidget(0, 2, new Label("c"));

我只想为 a 列设置橙色背景颜色。如何设置?请帮我。谢谢。

4

2 回答 2

1

尝试使用更易于管理的 CSS 样式。如果您以后想更改它,则无需触摸 JAVA 代码。

通过这种方式,您可以从主题中受益。

爪哇:

// set style for first row and first column
flexTable.getFlexCellFormatter().setStyleName(0, 0,"yellowBackground");

CSS:

.yellowBackground {
    background-color: yellow;
}
于 2014-05-09T09:05:09.117 回答
0

尝试这个:

  public void onModuleLoad() {
    FlexTable flexTable1 = new FlexTable(); 

    Label a = new Label("a");

    flexTable1.setWidget(0, 0, a);
    flexTable1.setWidget(0, 1, new Label("b"));
    flexTable1.setWidget(0, 2, new Label("c"));

    //add your widget to your panel, I used RootPanel directly for this example.
    RootPanel.get().add(flexTable1);

    a.getElement().getStyle().setBackgroundColor("orange");
  }
于 2014-05-09T08:28:11.867 回答