gpt4 book ai didi

java - SWT TableViewer 具有一个列或表项,其中多个按钮充当操作

转载 作者:行者123 更新时间:2023-12-02 00:03:48 24 4
gpt4 key购买 nike

我尝试在 SWT 中呈现包含以下行的下表:

名称1 | anotherProperty |BUTTON1(编辑) BUTTON2(删除) BUTTON3(停用)

使用SWT - Tableviewer adding a remove button to a column in the table我只能按列渲染一个按钮。

有办法做到这一点吗?

最佳答案

与添加单个按钮相同,您也可以添加多个按钮,但对于这些按钮,您将需要一个额外的容器。您可以尝试如下所示:

col.setLabelProvider(new ColumnLabelProvider() {
@Override
public void update(ViewerCell cell) {
TableItem item = (TableItem) cell.getItem();

Composite buttonPane = new Composite(getTable(), SWT.NONE);
buttonPane.setLayout(new FillLayout());

Button button = new Button(buttonPane,SWT.NONE);
button.setText("Edit");

button = new Button(buttonPane,SWT.NONE);
button.setText("Remove");

button = new Button(buttonPane,SWT.NONE);
button.setText("Deactivate");

TableEditor editor = new TableEditor(getTable());
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.setEditor(buttonPane, item, columnIndex);
editor.layout();
}
});

关于java - SWT TableViewer 具有一个列或表项,其中多个按钮充当操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14308221/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com