How to check the status of checkbox in java GUI?

前端 未结 3 1074
无人及你
无人及你 2021-01-05 12:32

I have around 200 hundred checkboxes in a Java GUI. Now I want to have the list of all checkboxes that have been checked by the user.

I can do it in one way like thi

3条回答
  •  天命终不由人
    2021-01-05 13:09

    Ummm, what should I say?

    OK, You should starts by using array to hold all check boxes you have so you can loop through it.

    In case that is too late, you may have a another choice by loop though all elements on that container (only work if all checkboxes are on the same container). Something like 'jPanel1.getComponents()' and then loop them only see which is a Checkbox.

    Anyway .. I think, you should put all those in an array and save yourself from a variable mess.

提交回复
热议问题