티스토리 뷰
오라클은 "대화 상자를 만드는 방법" 이라는이 주제를 잘 문서화했습니다. 이 문서는 사용자에게 입력을 요청하고 일부는 아이콘으로 일부 데이터를 표시하도록 프롬프트하는 다양한 종류의 대화 상자를 만드는 방법을 보여줍니다.
http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html
요구 사항에 대해 다음과 같이 할 수 있습니다.
...
while (true) {
try {
System.out.println("Esperando la conexion...");
gestor.agregarTexto("Esperando la conexion..");
connection = notifier.acceptAndOpen();
//Ask user if he/she wants to get connected to this device
int userChoice = JOptionPane.showConfirmDialog(
null,
"Would you like to connect to DEVICE_NAME?",
"Connection Request",
JOptionPane.YES_NO_OPTION);
if(userChoice == JOptionPane.YES_OPTION) {
// Create thread and come out of loop
Thread processThread = new Thread(new ProcessConnectionThread(connection));
processThread.start();
break;
}
else {
// user rejected the connection so close the connection here to allow other devices to connect
}
}
catch (Exception e) {
e.printStackTrace(); return;
}
}
...
출처
https://stackoverflow.com/questions/39940085