I am trying to create a message with a Yes or No button. Then a window will appear with a certain message that depends on if the user clicked Yes or No.
Here is my code:
public class test{
public static void main(String[] args){
//default icon, custom title
int n = JOptionPane.showConfirmDialog(
null,
"Would you like green eggs and ham?",
"An Inane Question",
JOptionPane.YES_NO_OPTION);
if(true){
JOptionPane.showMessageDialog(null, "HELLO");
}
else {
JOptionPane.showMessageDialog(null, "GOODBYE");
}
System.exit(0);
}
}
Right now it prints HELLO whether or not you press Yes or No. How do I get it to show GOODBYE when the user chooses No?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…