Here is my code that sets the values in the JComboBox
:
public void setDiscountNames(String type, JComboBox cbox) {
cbox.removeAllItems();
ArrayList<Discount> names = new ArrayList<Discount>();
try {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/abpp034?user=abpp034&password=120001772");
stmt = con.prepareStatement("SELECT Name FROM Discount WHERE Type = \"" + type + "\"");
rs = stmt.executeQuery();
List<String> strings = new ArrayList<String>();
while(rs.next()){
strings.add(rs.getString("Name")); // Confirm if "Name" is valid
}
cbox.addItem(strings);
} catch (SQLException ex) {
Logger.getLogger(Model.class.getName()).log(Level.SEVERE, null, ex);
}
}
Here is where I call the method and set the combo box with the values:
public DiscountGUIView() {
initComponents();
model.setDiscountNames("Fixed", jComboBox1);
}
Now the problem is I am getting this in my combo box [Travel Standard, Fixed Standard]
exactly as this when I click on my combo box.
Though I want it them to be split apart in their own index without the "[" and "]".