The list isn’t showing on the panel, however when I replace panel2.add(new JScrollPane(insuranceplan))
with panel2.add(insuranceplan)
, I can see the list but I can only select 1 item.
lab9 is a JLable/ insuranceplan is a Jlist / InsurancePlan is a string [];
lab9= new JLabel ("Insurance Plan");lab9.setBounds(10,150,165,25); insuranceplan = new JList(InsurancePlan) ; insuranceplan.setVisibleRowCount(3); insuranceplan.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); insuranceplan.setBounds(150,150,200,25); panel2.add(new JScrollPane(insuranceplan)); panel2.add(lab9);
Advertisement
Answer
Panel 2 seems to used absolute layout (based on your code).
You provide bounds for lab9
and insuranceplan
, but not for JScrollPane.