utapyngo
utapyngo

Reputation: 7146

Java SWT CheckedListBox

I could not find CheckedListBox in Java SWT. Please, point me to a way of extending List to support checkboxes.

Upvotes: 2

Views: 9714

Answers (4)

ZhekaKozlov
ZhekaKozlov

Reputation: 39536

Use JFace CheckboxTableViewer:

CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(
        parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);

Upvotes: 2

Phaedrus
Phaedrus

Reputation: 497

Just add SWT.CHECK to your TableViewer:

new TableViewer(container, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.SINGLE);

Creates a table that looks like this

Upvotes: 6

sonx
sonx

Reputation: 661

i've added a button selectAll on the above snippet and added the following event

Table table = new Table(shell, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    Button selectAll= new Button(parent, SWT.PUSH);
    selectAll.setFont(FontUtils.getMsSansSerifFont());
    selectAll.setLayoutData(gridData);
    selectAll.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            table.selectAll();
        }
    });

But the checkboxes are not selected?

Upvotes: 0

George Suaridze
George Suaridze

Reputation: 519

I think you can try to use table instead of list. Look at this snippet

Upvotes: 4

Related Questions