- String jid = StringUtils.parseBareAddress("jid");
- VCard vcard = new VCard();
- vcard.setJabberId(jid);
- try {
- vcard.load(SparkManager.getConnection(), jid);
- } catch (XMPPException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (vcard.getNickName() != null && vcard.getNickName().length() > 0)
- {
- // update nickname.
- ContactItem item = SparkManager.getWorkspace().getContactList().getContactItemByJID(jid);
- item.setNickname(vcard.getNickName());
- // TODO: this doesn't work if someone removes his nickname. If we remove it in that case, it will cause problems with people using another way to manage their nicknames.
- }
- String hash = vcard.getAvatarHash();
- // ImageIcon icon = new ImageIcon(hash);
- ImageIcon icon = VCardManager.getAvatarIcon(vcard);
- //这里是用于显示测试
- JFrame f = new JFrame();
- JLabel l = new JLabel(icon);
- f.getContentPane().add(l,BorderLayout.CENTER);
- f.pack();
- f.setVisible(true);
- //该片段来自于http://www.codesnippet.cn/detail/220420149352.html
来源: http://www.codesnippet.cn/detail/220420149352.html