how to bind ArrayList to JList

后端 未结 5 752
花落未央
花落未央 2020-12-10 18:44

i have a JList and an ArrayList.How to bind the datas in arraylist to the jlist.Are the any alternative methods?

    ArrayList arl = new ArrayList();
    ar         


        
5条回答
  •  半阙折子戏
    2020-12-10 19:27

    Another option is:

    DefaultListModel Jlista = new DefaultListModel();
    
    public Form1() {
    
     jList1.setModel(Jlista);
    
    }
    
    public void yourFunction(){
     Jlista.addElement("newElement");
    }
    

提交回复
热议问题