gpt4 book ai didi

java - 我有一个包含多列的表。是否可以使用 Jface 在每个列条目中创建一个单选按钮?

转载 作者:太空宇宙 更新时间:2023-11-04 12:45:05 24 4
gpt4 key购买 nike

我有一个包含多列的表。是否可以使用 JFace 在每个列条目中创建一个单选按钮?

我尝试使用TableEditor,但我只会向一列添加一个单选按钮,而不是向所有列添加一个单选按钮。我对 JFace 还很陌生,如果您能进一步指导我,我将不胜感激。

Example table

最佳答案

您应该为表格中的每一列/行添加一个单选按钮(第 0 列除外)。

for (int i = 0; i < employeeCount; i++)
{
TableItem item;
Button radio;
TableEditor editor;

item = new TableItem(table, SWT.NO_FOCUS);

item.setText(0, employees[i]); //Let's assume you have an array of employees' names

radio = new Button(table, SWT.RADIO);
//TODO: setup your radiobutton here (text, behavior, etc.)
editor = new TableEditor(table);
editor.setEditor(radio, item, 1); //1 is the column index (excellent)
editor.layout();

radio = new Button(table, SWT.RADIO);
//TODO: setup your radiobutton here (text, behavior, etc.)
editor = new TableEditor(table);
editor.setEditor(radio, item, 2); //2 is the column index (good)
editor.layout();

radio = new Button(table, SWT.RADIO);
//TODO: setup your radiobutton here (name, text, behavior, etc.)
editor = new TableEditor(table);
editor.setEditor(radio, item, 3); //3 is the column index (average)
editor.layout();

radio = new Button(table, SWT.RADIO);
//TODO: setup your radiobutton here (text, behavior, etc.)
editor = new TableEditor(table);
editor.setEditor(radio, item, 4); //4 is the column index (poor)
editor.layout();
}

这应该有效。

关于java - 我有一个包含多列的表。是否可以使用 Jface 在每个列条目中创建一个单选按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36409669/

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