In Java, I am using CheckboxTableViewer
to display a checklist for the user. I am populating the checklist using setInput method, as shown below. But for some reason, when I run my code, which resides in a Wizard Page, it shows the checkboxes but not the labels of the boxes (no text at all, as if I am passing empty strings). How can I fix the problem? Thank You. Below is my code
public void createControl(Composite arg0) {
Composite container = new Composite(arg0, SWT.NONE);
container.setLayout(new GridLayout());
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
container.setLayoutData(layoutData);
checkboxTableViewer = CheckboxTableViewer.newCheckList(container,
SWT.FULL_SELECTION | SWT.BORDER);
checkboxTableViewer.getTable().setLinesVisible(true);
checkboxTableViewer.getTable().setSize(500, 500);
checkboxTableViewer.setContentProvider(new ArrayContentProvider());
checkboxTableViewer.setLabelProvider(new ITableLabelProvider() {
public void removeListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
public Image getColumnImage(Object element, int columnIndex) {
// TODO Auto-generated method stub
return null;
}
public String getColumnText(Object element, int columnIndex) {
// TODO Auto-generated method stub
return null;
}
public void addListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
public void dispose() {
// TODO Auto-generated method stub
}
public boolean isLabelProperty(Object element, String property) {
// TODO Auto-generated method stub
return false;
}
});
checkboxTableViewer.setInput(new String[]{"zaid","saad","ahmad"});
checkboxTableViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
if (checkboxTableViewer.getCheckedElements().length > 0) {
enableNext = true;
} else {
enableNext = false;
}
checkStatus();
}
private void checkStatus() {
canFlipToNextPage();
// explicit call
getWizard().getContainer().updateButtons();
}
});
setControl(container);
}
Aucun commentaire:
Enregistrer un commentaire