在我的代码片段中!"checkBoxList"没有文件选择器选择并存储在其中的文件
复选框"tmp"它有文件的复选框!
当我在我的面板中显示文件[checkboxlist]时,它是未经检查的!我有选项后勾选/取消它.
我有以下代码用于选择/取消选择选项
我需要知道何时显示文件!文件应该显示为勾选(勾选)然后我可以修改我可以勾选/取消勾选.
我坚持这个逻辑!
[
编辑:我做了并更新了这部分的答案(见图).
我将select/deselectall添加到面板(框)并且它有效
box.add(chckbxSelectAll);
Run Code Online (Sandbox Code Playgroud)
&&我需要并且好奇知道如何将我的selectall复选框放在我的面板中
]
public void selectAllMethod() {
Iterator<JCheckBox> i = checkBoxList.iterator();
while (i.hasNext()) {
JCheckBox tmp = i.next();
if (chckbxSelectAll.isSelected()) {
tmp.doClick();
} else {
tmp.setSelected(false);
selectedCounter -= 1;
if (selectedCounter < 0) {
selectedCounter = 0;
}
noOfFileTxt.setText(Integer.toString(selectedCounter));
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的按钮选择方法,用于选择文件夹并在带有复选框的面板中显示它
public void chooseDirectoryFrom() {
String tempStr = null;
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
fileChooser = new JFileChooser();
Font font = new Font("Latha", Font.ITALIC, 10);
fileChooser.setFont(new Font("Latha", Font.PLAIN, 13));
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setFont(font); …Run Code Online (Sandbox Code Playgroud)