有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

复选框Java SWT CheckedListBox

我在Java SWT中找不到CheckedListBox。请告诉我一种扩展List以支持复选框的方法


共 (2) 个答案

  1. # 1 楼答案

    使用JFace CheckboxTableViewer:

    CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(
            parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    
  2. # 2 楼答案

    我在上面的代码片段中添加了一个按钮selectAll,并添加了以下事件

    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();
            }
        });
    

    但是复选框没有被选中