Gui JList ActionListener

♀尐吖头ヾ 提交于 2019-12-02 09:18:26

Ok so from what i understand this gonna take informations from Fields and put them into LIST that you have there

b2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent a)
        {
            DefaultListModel listModel = new DefaultListModel();
            listModel.addElement(t1.getText());
            listModel.addElement(t2.getText());
            listModel.addElement(t3.getText());
            listModel.addElement(t4.getText());
            list.setModel(listModel);


        }
    });

this i made simple for you so you can see what im doing i woud put txtfield to array so its easyer bud this will work for you just fine :)

You can do it with arrays and for loops so you can get rid off the listmodel.add .... etc each time and when you will want to sore all that info user put previously use for example arraylist.Im not sure how you expect your program to run next time when you post quesiton please point out exact problem and how do you expect program to work in detail.also post just relevant code not all of it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!