Before I asked this question, I went through many examples, some of them are related, but did not answer my needs:
I have a list as keyMessageList which includes id as Long and associated keyWord as String.
I displayed keyWord's name on my jpanel using following code:
for (KeyMessage obj : keyMessageList) {
checkBox = new JCheckBox(obj.getSmsKey());
displayKeywordPanel.checkBooxPanel.add(checkBox);
}
I got the following output:

Now, My requirement is: If I select keywords, I need to get the id associated with the selected keyword. I have done similar things many times in web applications like this, but now I need to do the same thing on swing. I used the following code on web application to fulfill the requirements.
Code for web:
<h:selectOneMenu id="branch" value="#{createUser.branchId}" required="true" requiredMessage="Please choose branch">
<f:selectItems value="#{allBranch}"/>
</h:selectOneMenu>
Can any swing expert please help me.
Note I may select multiple checkBox and keyMessageList returns from JPA query.
