2017-03-07 1 views
0

Kann mir jemand helfen, dieses Problem zu lösen.Wie kombiniere ich zwei oder mehr Bestätigungsdialoge in einem einzigen Bestätigungsdialog?

Hier habe ich das Zeichen der Ausgabe mit Premium-geprüft und schrieb die Bestätigung

image

Dialog

Hier habe ich das Zeichen von claimhandling mit Premium-geprüft und schrieb den Bestätigungsdialog

image

Benötigt: Ich brauche beide in einem einzigen Bestätigungsdialog, nicht separat wie in den obigen Bildern erwähnt.

Hier ist mein Code:

if(issuance !=null && prem.compareTo(totalzero) == 1 && issuance.compareTo(totalzero) == -1) { 
    ConfirmationDialog.showConfirmationDialog(this, 
     "the value of issuance has a different sign to the sign of premium"); 
} 
if(claimhandling !=null && prem.compareTo(totalzero) == 1 && claimhandling.compareTo(totalzero) == -1) { 
    ConfirmationDialog.showConfirmDialog(this, 
     "the value of claimhandling has a different sign to the sign of premium"); 
} 

Wenn beide „wenn“ Bedingungen zutreffen, dann muss ich die beiden Bestätigungsdialog in einem einzigen Dialog zu erhalten.

+2

Zeigen Sie uns den Code, der diese Dialoge anzeigt. ** [Bearbeiten] ** Ihre Frage. Do ** not ** Postleitzahl in Kommentaren. –

+1

Code immer noch nicht hinzugefügt! – Yazan

+0

if (ausgabe! = Null && prem.compareTo (totalzero) == 1 && ausgabe.compareTo (totalzero) == -1) {ConfirmationDialog.showConfirmationDialog ("Der Wert der Ausgabe hat ein anderes Vorzeichen als das Premiumzeichen "); if (beanspruchung! = null && prem.compareTo (totalzero) == 1 && claimhandling.compareTo (totalzero) == -1) {ConfirmationDialog.showConfirmDialog ("Der Wert von Claimhandling hat ein anderes Vorzeichen als das Premiumzeichen")); – Blessy

Antwort

1

Einfach die Nachrichten verketten und sicherstellen, dass sie als zwei Zeilen angezeigt werden. Ich weiß nicht, welche Art von Swing-Komponente Ihr ConfirmationDialog tatsächlich verwendet, aber die meisten Swing-Textkomponenten unterstützen einfach HTML-Tags zum Formatieren. Im folgenden Beispiel wird also eine neue Zeile mit <br> erstellt.

String message = ""; 
if (issuance !=null && prem.compareTo(totalzero) == 1 && issuance.compareTo(totalzero) == -1) { 
    message = "the value of issuance has a different sign to the sign of premium"; 
} 

if (claimhandling != null && prem.compareTo(totalzero) == 1 && claimhandling.compareTo(totalzero) == -1) { 
    if (message.length() > 0) { 
    message += "<br>"; 
    } 
    message += "the value of claimhandling has a different sign to the sign of premium"; 
} 

if (message.length() > 0) { 
    ConfirmationDialog.showConfirmationDialog(this, "<html>" + message+ "</html>"); 
} 
+0

Hallo @ a-Pferd-mit-kein-Name .. Ihre Antwort ist vollkommen richtig .. aber wie kann ich das gleiche implementieren im Falle von ConfirmationDialog .. Hier erweitert ConfirmationDialog die JOptionPane-Klasse. – Blessy

+0

Was meinst du mit "im Falle von implementieren"? –

+0

Vielen Dank @ a-Pferd-mit-kein-Name – Blessy

Verwandte Themen