I have an ArrayList that has many objects. For example:
ArrayList<Supplier> a = new ArrayList<>();
As you see it's an ArrayList from type Supplier
which is a class that has 4 attributes (name, company, address, phone number)
public class Supplier {
public String name;
public String company;
public String address;
public String phone_no;
}
I want to write JOptionPane.showInputDialog
statement that shows the list elements in a drop down list to choose one of them and after taking the choice I want to divide that choice into 4 attributes again from the same class.
This is my code, but it didn't work:
String []choices = null;
for(int i = 0; i < a.size(); i++) {
choices[i] = a.get(i).toString();
}
JOptionPane.showInputDialog(null, "Choose supplier of the product !!", "Select Supplier", JOptionPane.QUESTION_MESSAGE,null, choices, "----");