Below is part of some code I have written. I am trying to see whether nodes in a network are connected, and thus finding 'failurepoints'. I have a vector containing node Ids which I loop through to check for connections using a hasPath method. This all works fine, but my problem is with the output. I want to indicate to a user whether or not a node they selected (earlier in the program) is a failure point, by outputting some dialog. However when I run the program, the JOptionPane message panel keeps reappearing multiple times (I'm guessing 'i' number of times) and I can't get rid of it without pressing ok or the 'x' button multiple times (a problem if I get a huge network, lots of button presses required!). Can anyone see what I can do to make the panel appear only once? Thanks in advance.
for (int i = 1; i< cnodes.size();i++){
boolean isConnected = hasPath(cnodes.elementAt(0), cnodes.elementAt(i), selectedNodes[0], network);
boolean OneKid = false;
if (cnodes.size() < 2) {
OneKid = true;
}
boolean FailurePoint;
if ((isConnected == true)|| (OneKid == true)) {
FailurePoint = false;
JOptionPane.showMessageDialog(null,
"The selected node is not a failure point.",
"Result", JOptionPane.INFORMATION_MESSAGE);
}
else if (isConnected == false){
FailurePoint = true;
JOptionPane.showMessageDialog(null,
"The selected node is a failure point.",
"Result", JOptionPane.INFORMATION_MESSAGE);
}
else if ((isConnected !=false) && (isConnected !=true)){
JOptionPane.showMessageDialog(null,
"The selected node is not a failure point.",
"Result", JOptionPane.INFORMATION_MESSAGE);}
}
}