是否有可能使一个对话框,结束脚本? [英] Is it possible to make a dialog box end a script?

查看:122
本文介绍了是否有可能使一个对话框,结束脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用日食将某个应用为我的编程类,我已经尝试不同的东西弄清楚如何使脚本停止运行。我想这将是一个if语句来关闭它,但我不能弄明白。

I'm making an app for my programming class using eclipse and I've tried different things to figure out how to make the script stop running. I'm thinking it will be an if statement to close it, but i can't figure it out.

我在做什么:

JOptionPane.showConfirmDialog(null, "do you plan on attending a local technology center?"); 

当我使用code它会弹出一个对话框,说是否,取消。我如何才能让当用户点击否,取消甚至在X在盒子的右上角的脚本上停止运行?我不知道是什么code使用。

When I use that code it pops up a dialog box saying "yes" "no" "cancel". How could I make the script stop running when the user clicks "no" "cancel" or even the X in the top right of the box? I do not know what code to use.

推荐答案

您可以使用的JOptionPane 对话框作为遵循

int dialogButton= JOptionPane.YES_NO_CANCEL_OPTION;
int dialogResult = JOptionPane.showConfirmDialog(null, "Your Message", "Dialog box title",dialogButton);
if(dialogResult==JOptionPane.YES_OPTION){
//Code for YES Button Clicked
}
else if(dialogResult==JOptionPane.NO_OPTION)
{
//Code for NO Button Clicked
}
else if(dialogResult==JOptionPane.CANCEL_OPTION){
//Code for CANCEL Button Clicked
}

这篇关于是否有可能使一个对话框,结束脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆