简体   繁体   中英

Getting the text of all the Selected Checkbox in Java

So I'm doing a project that requires a lot of checkboxes. And all those selected checkboxes will go to the texture or something trigger by a button. I already browse here and I came up with this.

pnchk是放置复选框的面板。

The code actually is almost what I'm looking for. But the problem is the way it displays.

显示

What I want is to remove those [ , ] because I want to be the one who controls the way the text is display.

Well, passing the checkboxes List to the showMessageDialog method is implicitly calling List#toString() . The implementation of this method in class ArrayList is to print a comma-separated list of the values, just as you see it. If you want to display it in another way, you'd have to iterate over the elements of your list and build a string according to your likings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM