Blessy
Blessy

Reputation: 35

How do I combine two or more confirmation dialog in a single confirmation dialog?

Can any one help me to solve this issue.

Here I have checked the sign of Issuance with Premium and wrote the confirmation dialog

image

Here I have checked the sign of claimhandling with premium and wrote the confirmation dialog

image

Needed: I need both in a single confirmation dialog, not separately as mentioned in above pictures.

Here is my 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");
}

If both "if" conditions are true then I need to get the both confirmation dialog into a single dialog.

Upvotes: 0

Views: 98

Answers (1)

user330315
user330315

Reputation:

Simply concatenate the messages and make sure they are displayed as two line. I don't know what kind of Swing component your ConfirmationDialog is actual using, but most of the Swing text compontents support simply HTML tags for formatting, so the below example uses a <br> to create new line.

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>");
}

Upvotes: 1

Related Questions