如何判断java中对话框的选项?

来源:百度知道 编辑:UC知道 时间:2024/05/17 23:00:11
我想根据对话框YES_option 或者是 NO_option 来进行判断~
比如选择NO的话,就return,不执行下面的代码,
记得按钮的返回值是int类型的,可是具体的想不起来了,
请高手来帮忙~万分感谢!
一楼的方法看不懂呀~我试过了~可是没有效果~

都在JOptionPane里定义的:
/** Return value from class method if YES is chosen. */
public static final int YES_OPTION = 0;
/** Return value from class method if NO is chosen. */
public static final int NO_OPTION = 1;
/** Return value from class method if CANCEL is chosen. */
public static final int CANCEL_OPTION = 2;
/** Return value form class method if OK is chosen. */
public static final int OK_OPTION = 0;
/** Return value from class method if user closes window without selecting
* anything, more than likely this should be treated as either a
* <code>CANCEL_OPTION</code> or <code>NO_OPTION</code>. */
public static final int CLOSED_OPTION = -1;

举例:
import javax.swing.JOptionPane;

public class Choose {
public static void main(String[] args) {
int rv = JOptionPane.showCon