mardi 15 août 2017

How would I display a varying amount of checkboxes?

I'm rather new to programming, so please bear with me if I'm a bit ignorant. I've created a program with the purpose of randomly choosing an object, and displaying the name and icon contained within. These icons and names are chosen from an imported text document, making adding more entries as easy as adding another line to the document. I should add that the program is using a UI generated by NetBeans. I think it's using a UI builder called Swing or JFrame. This all works fine.

My problem is that I'm looking to add checkboxes to the interface, so I can exclude individual objects from the randomzier. I need a way to make the program create a checkbox for each object contained in the ArrayList I've created them in. I'm drawing a complete blank here, so I don't have any code to show. What are some ways to achieve this? It should be expandable by just adding lines to the imported text document, and without recompiling.

I'm thinking that I'll make the program check whether the object that is randomly chosen is checked or not. If it is unchecked, it should choose another one. This part I think I'll be able to do, but the checkboxes them selves, I'm having trouble with.




Aucun commentaire:

Enregistrer un commentaire