新浪微博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中新建对象!!