【发布时间】:2013-11-28 21:44:12
【问题描述】:
我正在制作一个聊天客户端,但我遇到了一些代码无法运行的问题。
public static void login(String userName, String password) throws XMPPException {
ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com",5222,"Work");
connection = new XMPPConnection(config);
try{
connection.connect();
connection.login(userName, password);
System.out.println("Login Successful");
//gui.removeAll();
URL temp = start.class.getResource("slate.png");
gui.window.remove(gui.password);
gui.window.remove(gui.username);
gui.window.remove(gui.login);
gui.window.remove(gui.failed);
gui.window.setContentPane(new JLabel(new ImageIcon(temp)));
gui.window.setBackground(new Color(27,27,27));
System.out.println("Reached 1");
//displayBuddyList();
gui.list2.setVisible(true);
System.out.println("Reached 2");
gui.list2.setText("text test");
System.out.println("Reached 3");
}
catch(Exception e){
gui.failed.setVisible(true);
}
}
"gui.list2.setVisible(true)" 和 "gui.list2.setText("TestText")" 行接缝不起作用。但我得到了所有 System.out.println 消息。
“list2”是一个JTextArea,它已经添加了我一直使用的JFrame: 这是我的 gui 类中的代码:
window.add(list2);
list2.setBounds(0,0,window.getWidth(),window.getHeight());
list2.setVisible(false);
所有代码供进一步调查:http://pastebin.com/PcSPzgBN
【问题讨论】:
-
这一切都发生在美国东部时间吗?如果是这样,是否有其他东西干扰了 EDT?
-
把 gui.list2.setVisible(true); 在 setText 调用之后。
-
@Quirliom 没用。
-
和@John3136 什么是 EDT?
-
EDT 是事件调度线程。如果你把它卡住,Java 就没有机会为你画东西了。