[英]How to add JOptionPane when you press Agree
我想創建一個自定義jOptionPane,而不是/是,但同意/不同意。 當我按“同意”時,我想要一個showMessageDialog框。 你能幫我嗎?
JFrame frame = new JFrame();
String[] options = new String[2];
options[0] = "Agree";
options[1] = "DISAGREE";
JOptionPane.showOptionDialog(frame.getContentPane(),"Would you like to
continue?","Message",
0,JOptionPane.INFORMATION_MESSAGE,null,options,null);
希望對您有幫助。
JFrame frame = new JFrame();
String[] options = new String[2];
options[0] = "Agree";
options[1] = "DISAGREE";
int result= JOptionPane.showOptionDialog(frame.getContentPane(),"Would you like to continue?","Message",
0,JOptionPane.INFORMATION_MESSAGE,null,options,null);
if(result==1){//when disagree
JOptionPane.showMessageDialog(frame, "Disagree!");
}else if(result==0){//when agree
JOptionPane.showMessageDialog(frame, "Agree!");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.