的方法serverinititaor()初始化(5555)在serverinitiator類是沒有得到所謂的在下面的代碼。方法不會被調用
此方法將啓動一個新框架客戶端上的端口5555像發送郵件或聊天宗旨一些功能。
public static void main(String[] args) {
new Thread(new Runnable() {
public void run() {
frame = new JFrame("client list");
panel = new JPanel();
JButton button = new JButton("Refresh Client list");
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
if(success){
JButton jb = new JButton("A new Client on port 5555");
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new ServerInitiator().initialize(5555);
}
});
panel.add(jb);
frame.revalidate();
}
}).start();
}
ServerInitiator.java
synchronized public void initialize(int port){
try {
final ServerSocket sc = new ServerSocket(port);
System.out.println(SwingUtilities.isEventDispatchThread());
drawGUI();
new Thread(new Runnable(){
public void run()
{
try {
Socket client = sc.accept();
System.out.println("New client Connected to the server");
new ClientHandler(client,desktop);
} catch (IOException ex) {
}
}
}).start();
} catch (IOException ex) {
ex.printStackTrace();
}
}
請回復。
謝謝。
其中'serverinititaor()。initialize(5555)'。 – Braj
你甚至設法得到這個編譯? – ejk314