Gui JList ActionListener

前端 未结 1 1101
梦毁少年i
梦毁少年i 2021-01-27 09:09

hey all goodevening i have a problem about my second button named \"Submit\" because i cant transfer all information i entered to my null JList in the frame here is my code so f

相关标签:
1条回答
  • 2021-01-27 09: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.

    0 讨论(0)
提交回复
热议问题