Dyapa Srikanth Dyapa Srikanth - 4 months ago 48
Java Question

how to add list of checkboxes [combo boxes] to JScrollPane in java netbeans swing application

I have a list of names and associated values to create checkboxes like

["SAMABULA","CARPETS INTERNATIONAL","HRM/TRAINING"]
["091","094","003"]


How to create checkboxes with these values add these checkboxes to JScrollPane in netbeans IDE.

This is a Swing applicaiton. I created a window from pallete and added jscrollpane to that window. But I don't know how to add list of checkboxes to that scrollpane.

Please help me.

Answer

@ Srikanth Dyapa

there are two areas

you have already JList that's contains JCheckBox(es)

then you just declare

JScrollPane myScrollPane = new JScrollPane(myList);

or you have to put your JCheckBox to JList or JPanel but for JPanel with correct LayoutManager for example GridLaoyut

thenarter add your JList or JPanel to the JScrollPane as is above mentioned

maybe ButtonGroup Component can help you with that