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) {
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());

Edited 6 Years Ago by StephNicolaou: n/a

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.

This article has been dead for over six months. Start a new discussion instead.