Thank you for your reply. My code is like this:
.....
private void updateRoleCombo()
{
String[] avrole = new String[]{""};
try {
avrole = (_parent._security).getRoleList(_parent._token); // retrieve the new list from the database
} catch (RemoteException ex2) {
JOptionPane.showMessageDialog(_parent, ex2, "Error",
JOptionPane.ERROR_MESSAGE);
}
_role.removeAllItems();
for (int i = 0; i < avrole.length; i++)
{
_role.addItem((String)(avrole[i]));
}
_role.setSelectedIndex(0);
}
......
_role = new JComboBox(rolelist);
add(_role);
_role.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
updateRoleCombo();
}
public void focusLost(FocusEvent e) {
}
});