您的位置:首页 > 其它

jList使用中问题的解决

2013-06-02 20:18 106 查看
新浪微博API提供了强大的功能,这两天玩儿的挺开心。
在用jList显示好友列表时出现了问题。
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
//new Haoyou().setVisible(true);
Haoyou haoyou = new Haoyou();
haoyou.setVisible(true);
haoyou.haoyouLiebiao();
}
});
}

public void haoyouLiebiao() {
String access_token = WeiboConfig.getValue("access_token");
String uid = WeiboConfig.getValue("uid");
Friendships fm = new Friendships();
fm.client.setToken(access_token);
Timeline tm = new Timeline();
tm.client.setToken(access_token);
DefaultListModel m = new DefaultListModel();
try {
UserWapper users = fm.getFriendsBilateral(uid);

for (User u : users.getUsers()) {
m.addElement(u.getName().toString());
}
System.out.println(m);

jList1.setModel(m);
} catch (WeiboException e) {
e.printStackTrace();
}
}
重点是在Main中新建对象!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  public void 新浪微博