I'm not sure if this is the best way but I would like to display a list of addresses in a combo box where the columns come from different tables such as Countries, Cities and Types (work and home).

I don't want to display the countryID or cityID, etc. but for know I have simply selected all from the address table to start getting this to work.

Problem: From using the code below, only the first column appears.

if(vehicleAccessType == 1) {
getDBConnection();
try {
stmt = conn.createStatement();
if(stmt.execute("SELECT * FROM Collection_Addresses.CollectionAddressID, Collection_Addresses.AddressLine, Collection_Addresses.AddressLine2, Collection_Addresses.Postcode FROM Collection_Addresses, Clients WHERE Collection_Addresses.CollectionAddressID = Clients.CollectionAddressID")) {
rs = stmt.getResultSet();
}
while(rs.next()) {
cbCustomerAddresses.addItem(new AddressComboBoxItem(rs.getInt(1), rs.getString(2).trim(), rs.getString(3).trim(), rs.getString(4).trim());
}
}
catch (SQLException ex) {
	System.out.println("SQLException: " + ex.getMessage());
	return;
	}
}

You didn't post the AddressComboBoxItem class, so no one can see what that does.
I can tell you that the combo box is going to display whatever your item's toString() method returns, unless you have created a custom renderer for it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.