Hi guys,

Anybody know how to generate checkboxes dynamically if i want to generate them with the result i have fetched from a database query.

The query would be like that,
SELECT calltype From table Where phone_no=123456;

Now result of this query will vary everytime, there total number of checkboxes would also be varying everytime......

Please give me a solution as i'm a beginner and stuck into this problem.

Regards

if you're a beginner, you might want to start with some easier tasks.
I haven't try this for myself, but I think the next sollution might work.
you get an array of results from your db, which means you know how many checkboxes you need.
so, you create an array that contains that number of checkboxes.
after that, you add those to your GUI.

Thanks for the suggestion, but i have done all the basic things to do in java swings & also i have a deadline to meet.....
So can you suggest any piece of code/snippet.
It'll be very helpful.....
Thanks.....

we don't deliver custom made code ...
I provided you with some logic you could follow, if you know how to create a checkbox and how to work with arrays, you should be able to try that

we don't deliver custom made code ...
I provided you with some logic you could follow, if you know how to create a checkbox and how to work with arrays, you should be able to try that

He is right. When you run the query save the results in list or an array. Then loop that array and create with each loop a different checkbox. Then use those checkboxes in any way you want.

Also if you are using a GUI builder for your gui then it will not work for a variable number of checkboxes

He is right. When you run the query save the results in list or an array. Then loop that array and create with each loop a different checkbox. Then use those checkboxes in any way you want.

Also if you are using a GUI builder for your gui then it will not work for a variable number of checkboxes

Hey, I finally got the solution as told by you people. Thanks for the idea, i really appreciate it.
I will put my code snippet to this thread sometime later when I complete the application to help other people.

Regards.

just mark this thread as solved as it is: "solved"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.