2017-06-08 2 views
1

私はChessのための小さなサーバークライアントシステムを開発しています。ユーザーは他のユーザーにゲームを尋ねることができ、問題があります。クライアントはサーバーにメッセージを送信し、サーバーはそのメッセージを直接他のクライアントに送信し、他のクライアントはメッセージを取得します。メッセージを受け取った後、クライアントはAlertを開いて、他のクライアントとプレイしたいかどうかを選択する必要がありますが、単に開くことはできません。ここに私のコードはJavaFX 8 - アラートが開かない

} else if (readed.equals("+anfrage")){ 
    String n=clientSocket.readLine(); 
    Alert in=new Alert(AlertType.CONFIRMATION);  //here the program stucks 
    in.setHeaderText("Spielanfrage von: "+n); 
    in.getButtonTypes().clear(); 
    in.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO); 
    in.setResizable(false); 
    Optional<ButtonType> opt=in.showAndWait(); 
    if (opt.get()==ButtonType.YES) { 

    } else{ 

    } 

答えて

0
Alert alert = new Alert(AlertType.CONFIRMATION, " Your Message" + selection + " ?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL); 
alert.showAndWait(); 

if (alert.getResult() == ButtonType.YES) { 
    //do stuff 
}else{ 
    //do other stuffs 
} 
関連する問題