Reputation: 133
I have the following code:
clientTableList = new Object[DBQueries.getAllClients().size()][3]; [I want to load 3 records for now]
LinkedHashMap<String, LinkedHashMap<String, String>> ClientHashMap = DBQueries.getAllClients();
System.out.println(clientHashMap.keySet());
//Printing all Values
System.out.println(clientHashMap.values());
Results:
[Bob Hope, Elena Hairr, Blossom Kraatz, Loreen Griepentrog]
[{UserID=2345, GivenName=Bob, FamilyName=Hope, DateOfBirth=August 30, 1963, NameSuffix=Sr, NamePrefix=, [email protected], Phone=519- ...
I need to load a JTable
, my next code is:
for (int i = 0; i < clientHashMap.size(); i++) {
clientTableList[i] = new Object[] {
clientHashMap.get("GivenName") + " " + clientHashMap.get("FamilyName"),
clientHashMap.get("LoginEmail") + " ",
clientHashMap.get("Phone") + " "
};
But I'm getting all null
for my clientTableList
.
I need to load all values into a HashTable
then load the HashTable
into clientTableList
. Right?
Upvotes: 1
Views: 209
Reputation: 133
Following changes worked:
clientTableList[i++] = new Object[]{ client.get("GivenName") + " " + client.get("FamilyName") , client.get("LoginEmail") + " " , client.get("Phone") + " " };
Upvotes: 0
Reputation: 6197
Your clientTableList
doesn't have those fields, only its values have them:
int i = 0;
for (Map<String, String> client: clientHashMap.values()) {
clientTableList[i++] = String.format("%s %s %s %s",
client.get("GivenName"),
client.get("FamilyName"),
client.get("LoginEmail"),
client.get("Phone"));
};
Upvotes: 1