जेडीके 8u40 के बाद से, मैं एक पुष्टिकरण संवाद प्रदर्शित करने के लिए नया javafx.scene.control.Alert
एपीआई का उपयोग कर रहा हूं। नीचे दिए गए उदाहरण में, "हाँ" बटन डिफ़ॉल्ट रूप से "नहीं" बटन के बजाय ध्यान केंद्रित है:जावाएफएक्स डिफ़ॉल्ट फोकस बटन अलर्ट संवाद
public boolean showConfirmDialog(String title, String header, String content, AlertType alertType) {
final Alert alert = new Alert(alertType);
alert.setTitle(title);
alert.setHeaderText(header);
alert.setContentText(content);
alert.getButtonTypes().clear();
alert.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO);
final Optional<ButtonType> result = alert.showAndWait();
return result.get() == ButtonType.YES;
}
और मैं नहीं जानता कि यह कैसे बदलने के लिए।
संपादित करें:
यहाँ परिणाम का एक स्क्रीनशॉट जहां "हाँ" बटन डिफ़ॉल्ट रूप से केंद्रित है:
भी देखें: http://stackoverflow.com/a/37610648/59087 –