在表格中添加text便加框
private void createTableText(Table table) { TableEditor editor = new TableEditor(table); for (int i = 0; i < table.getItemCount(); i++) { editor = new TableEditor(table); Text text = new Text(table, SWT.BORDER); counts.add(text); text.pack(); editor.minimumWidth = text.getSize().x; editor.horizontalAlignment = SWT.CENTER; editor.setEditor(text, table.getItem(i), 2); //第三个参数为列数,即text要显示的位置 } }
主要是用到了TableEditor.界面如下: