I have a Table with multiple columns. Is it possible to create a radio button in each column entry using JFace?
I tried to use TableEditor
with this I would only add one radio button to a column not on to all columns. I am pretty new to JFace it would be greatly appreciated if you can guide me further on this.
答案 0 :(得分:0)
答案 1 :(得分:0)
您应该为表中的每个列/行添加一个单选按钮,但第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();
}
这应该有效。