- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含 4 列的表格,第四列充满了 CHECK 样式的按钮。
问题是每次我执行 removeAll() 以用其他内容填充表格时,按钮都不会被删除,因此我可以在同一行中看到具有相同状态的相同按钮。
这是我的 table :
Table membersTable = new Table(clubComposite, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION);
membersTable.setLinesVisible(true);
membersTable.setHeaderVisible(true);
membersTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
TableColumn tblclmnName = new TableColumn(membersTable, SWT.NONE);
tblclmnName.setWidth(150);
tblclmnName.setText("Nombre");
TableColumn tblclmnCommonPhoneNumber = new TableColumn(membersTable, SWT.NONE);
tblclmnCommonPhoneNumber.setWidth(120);
tblclmnCommonPhoneNumber.setText("Teléfono");
TableColumn tblclmnCommonMoney = new TableColumn(membersTable, SWT.NONE);
tblclmnCommonMoney.setWidth(150);
tblclmnCommonMoney.setText("Participación Habitual");
TableColumn tblclmnPayed = new TableColumn(membersTable, SWT.CENTER);
tblclmnPayed.setWidth(50);
tblclmnPayed.setText("Payed");
这就是我填充表格的方式,您还可以看到按钮:
// populate Table
for (int i=0; i<50; i++) {
TableItem tableItem = new TableItem(membersTable, SWT.NONE);
tableItem.setText(new String[] {"person "+i, "610610620", "100"});
Button button = new Button(membersTable, SWT.CHECK);
button.pack();
TableEditor editor = new TableEditor(membersTable);
editor.minimumWidth = button.getSize().x;
editor.horizontalAlignment = SWT.CENTER;
editor.setEditor(button, tableItem, 3);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
//how to know in which row is clicked the checkbox?
}
});
}
最佳答案
TableEditor
不是 TableItem
并且不会被 removeAll
删除(也不会被 clearAll
删除)。
可以通过编程方式处理相应的控件,例如:
membersTable.removeAll();
Arrays.stream(membersTable.getChildren()) // stream over all children
.filter(Button.class::isInstance) // only the Buttons
.forEach(Control::dispose); // and dispose it
或(同上)
membersTable.removeAll();
for(Control control : membersTable.getChildren()) {
if (control instanceof Button) {
control.dispose();
}
}
或者,将 TableEditor
保存在列表中并释放它们的编辑器:
List<TableEditor> editors = new ArrayList<>();
...
membersTable.removeAll();
editors.stream() // stream over TableEditors
.map(TableEditor::getEditor) // get their Editor (a Control)
.forEach(Control::dispose); // dispose it
editors.clear();
关于Java SWT : removeAll() in TABLE doesn't delete my buttons on the rows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52440051/
我不确定 groovy 中的 removeAll 是如何工作的,但我希望它会返回 [40289454470ea94601470ea977d00018] def list = ['40289454470
我在使用 Netbeans 制作的 Java 应用程序中遇到了奇怪的问题。这是一款内存卡游戏。主类是一个 JFrame,它保存相同大小的面板。面板通过网格布局进行分割,每个单元格都包含一张卡片,另一个
List vAllBatchList = getAllBatchCollection().toList(); //Has 700k records List vKeepableBatchCollect
我编写了一个通用的 Partition 类(分区是将一个集合划分为不相交的子集,称为部分)。在内部这是一个 Map和一个 Map> ,其中整数是零件的标签。例如partition.getLabel(T
我有两个自创建类对象的数组列表。比较后,我从两者中删除了公共(public)对象,并准备了获取公共(public)元素的方法。找到公共(public)元素后,我通过调用 removeAll() 方法删
我想要编写一段代码,它接受一个列表列表,将其拆分为 9 个子列表,并从每个子列表中的所有列表中删除数字。但是,当我的代码运行时,它会从所有列表中删除数字,而不仅仅是从原始列表中获取的部分 for (i
我是 Linq 的新手。根据我的理解,LINQ 应该只用于查询而不用于修改集合或数据库等。 如果是这样,微软为什么要提供 RemoveAll() 扩展? 据我所知,RemoveAll() 修改集合。
有人可以解释为什么以下内容无法按我的预期工作吗? 按下“应该”按钮会导致显示仅包含(空的)JScrollPane,即输入字段和按钮应该消失。但是,它们会一直保留到调整组件大小为止... public
我有一个超过 400 行的列表。每行看起来都类似于:example-example123 我想删除“-”之后的所有内容,这样我只剩下开头部分:example123任何帮助将不胜感激。 最佳答案 像这样
我有两个 for 循环来从列表中删除项目。我正在为这些循环寻找等效的 LINQ 语句 for (Int32 i = points.Count - 1; i >= 0; i--) { for (
我有一个页面,将 View 模型绑定(bind)到 jQuery UI 对话框内的 HTML 表。 当用户关闭对话框时,我想删除 viewmodel observableArray 中绑定(bind)
myGenericList.RemoveAll(x => (x.StudentName == "bad student")); 效果很好,但绑定(bind)列表没有此方法。如何为绑定(bind)列表创
我使用数组列表来查找两个字符串(即 str2 和 str3)之间的差异。当我使用下面的代码时,它工作正常并返回预期的输出。但当我更换时 str2 = #19, 6th cross, 7th main
我有一个小问题,数组列表中的元素没有被删除。这是一个数组列表。这是我的代码: package net.lucrecious.armorconstruct.helpers; import java.ut
我有成员类的简单ArrayList: ArrayList mGroupMembers = new ArrayList<>(); ArrayList mFriends = new ArrayList<>
我预计结果如下,但实际上没有。尽管当我尝试使用字符串而不是项目对象时它起作用了。我想知道为什么会这样以及如何编码以获得预期结果。谢谢。 EXPECTED -----------------------
我有以下代码: ActionListener listenerComboVehicle = new ActionListener() { @Override public void a
(我已经根据“removeall where”或“removeall two argument predicate”的关键字做了尽可能多的搜索,但运气不佳,所以这里开始) 问题是我有一个对象列表(Wa
在通过 NHibernate 检索集合时,我遇到了无法使用 .RemoveAll 的问题。 我有一个名为 Order 的实体,我通过 NHibernate 保留它。 Order 有很多 OrderIt
我有两个列表,我们称它们为列表 A 和列表 B。这两个列表都包含名称并且没有重复项(它们是唯一值)。列表 B 中的每个名称都可以在列表 A 中找到。我想找出列表 B 中缺少哪些名称,以便将这些缺少的名
我是一名优秀的程序员,十分优秀!