Witam
Mam mały problem. Stworzyłem sobie tabele z edytowalnymi polami. Z jedną kolumną ale tabela ma większy rozmiar od kolumny i wygląda to tak jak w załączniku.
próbowałem:
mojaTabela.pack();
ale wciąż ten "dzyndzel" wystaje. A chciałbym go się pozbyć. ( Ale nie przez zastąpienie tabeli listą )
Dziękuje z góry za poświęcony czas i pomoc.
Dodaje kod: ( Którego większość to kopia z tutoriala )
final Table table = new Table(sectionComposite, SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
//table.setItemCount(10);
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumn column1 = new TableColumn(table, SWT.NONE);
// TableColumn column2 = new TableColumn(table, SWT.NONE);
for (int i = 0; i < 1; i++) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[] { "item " + i});
}
column1.setText("Entry criteria");
column1.setWidth(200);
column1.setResizable(false);
column1.pack();
// column2.pack();
final TableEditor editor = new TableEditor(table);
// The editor must have the same size as the cell and must
// not be any smaller than 50 pixels.
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.minimumWidth = 50;
// editing the second column
final int EDITABLECOLUMN = 0;
table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// Clean up any previous editor control
Control oldEditor = editor.getEditor();
if (oldEditor != null)
oldEditor.dispose();
// Identify the selected row
TableItem item = (TableItem) e.item;
if (item == null)
return;
// The control that will be the editor must be a child of the Table
Text newEditor = new Text(table, SWT.NONE);
newEditor.setText(item.getText(EDITABLECOLUMN));
newEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent me) {
Text text = (Text) editor.getEditor();
editor.getItem().setText(EDITABLECOLUMN, text.getText());
}
});
newEditor.selectAll();
newEditor.setFocus();
editor.setEditor(newEditor, item, EDITABLECOLUMN);
}
});
table.setSize(table.computeSize(SWT.DEFAULT, 200));
GridData gd = new GridData();
table.setLayoutData(gd);
Pozdrawiam