弹出JAVA消息

弹出JAVA消息,java,swing,Java,Swing,//我想添加消息弹出窗口,如果你是对的,它表明你的答案是正确的,恭喜 //如果出现错误,则表明您的答案不正确。请重试您可以通过显示警报对话框来执行此操作,请查看以下内容: if(answers[index] != 'A') answer_labelA.setForeground(new Color(255,0,0)); //It shows if the button that you choose is correct, the button become color gree

//我想添加消息弹出窗口,如果你是对的,它表明你的答案是正确的,恭喜


//如果出现错误,则表明您的答案不正确。请重试

您可以通过显示警报对话框来执行此操作,请查看以下内容:
if(answers[index] != 'A')
        answer_labelA.setForeground(new Color(255,0,0)); //It shows if the button that you choose is correct, the button become color green and wrong become color red
    if(answers[index] != 'B')
        answer_labelB.setForeground(new Color(255,0,0)); //It shows if the button that you choose is correct, the button become color green and wrong become color red
    if(answers[index] != 'C')
        answer_labelC.setForeground(new Color(255,0,0)); //It shows if the button that you choose is correct, the button become color green and wrong become color red
    if(answers[index] != 'D')
        answer_labelD.setForeground(new Color(255,0,0)); //It shows if the button that you choose is correct, the button become color green and wrong become color red