简体   繁体   中英

how can I fix my JList? It's not appearing

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);

Panel 2 seems to used absolute layout (based on your code).

You provide bounds for lab9 and insuranceplan , but not for JScrollPane.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM