1
나는 java를 처음 사용했습니다. 나는 버튼서버 버튼 닫기 문제
JButton startServerButton = new JButton("Start");
startServerButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Start")) {
Runnable serverRunnable = new Runnable() {
public void run() {
runServer();
}
};
Thread serverThread = new Thread(serverRunnable);
serverThread.start();
}
}
});
내 서버를 시작하고 난 버튼
JButton endServerButton = new JButton("End");
endServerButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("End")) {
closeConnection();
}
}
});
하지만 닫기 버튼 나던 작업으로 닫으시겠습니까 ... 도와주세요!
1) 다음 연결을 소켓 종료 후 시작 스레드 'IO &를 새 스레드에서 끝을 작업을 넣고 : 여기
private void closeConnection() {
displayMessage("\nTerminating connection\n");
try {
output.close();
input.close();
connection.close();
} catch (IOException ioException) {
ioException.printStackTrace();
}
게시하지 않은 다른 코드에 문제가있는 것 같습니다. 정확하게 오류가 무엇입니까? –