how would i go about collecting data from 4 JTextFields such as name,address, home num, mobile num. and then combining them into one string so they can be one item in a JList? eg
luke, highway road, 929382094, 03740324
any help would be great thanks
how would i go about collecting data from 4 JTextFields such as name,address, home num, mobile num. and then combining them into one string so they can be one item in a JList? eg
luke, highway road, 929382094, 03740324
any help would be great thanks
Get the contents of each of the text fields, use the + operator to create a new string (or String.format()) and then add that string as an element of the list.
It's hard to see what the actual problem is here. (Unfamiliarity with String operations? with Swing? with the particular methods of lists and text fields?) Perhaps you could post your attempt.
kind regards,Code:JTextField tf1, tf2, tf3, tf4;
...
String result= tf1.getText()+", "+tf2.getText()+", "+tf3.getText()+", "+tf4.getText();
Jos
A better approach would be to use a JTable (instead of the JList). Then the data from each text field represents a column in the table and you update the TableModel by using the addRow(...) method of the DefaultTableModel.