继续或取消java
好的,我对编程非常陌生,我正在做一个非常基本的税务程序。我不能使用jQuery。 我需要创建一个从用户返回stop或continue的方法。 那么我需要:继续或取消java,java,while-loop,Java,While Loop,好的,我对编程非常陌生,我正在做一个非常基本的税务程序。我不能使用jQuery。 我需要创建一个从用户返回stop或continue的方法。 那么我需要: while (answer equals continue){ code code code call a method that returns either stop or continue from the user }//end of while 我尝试在方法中使用JOptionPane,但在“w
while (answer equals continue){
code
code
code
call a method that returns either stop or continue from the user
}//end of while
我尝试在方法中使用JOptionPane,但在“while”部分我不知道如何使用该方法。您需要将对话框(JOptionPane)的结果存储在布尔变量中。比如:
boolean cnt = true;
while (cnt) {
//... Do the stuff you want to do ...
//update cnt variable using a JOptionPane
cnt = JOptionPane.YES_OPTION == jOptionPane1.showConfirmDialog(this, "Do you want to continue?");
}
认真地你理解你的问题吗?你想在什么条件下停止或继续?jQuery是一个基于JS的库,可以在web应用程序中使用,而在web应用程序中使用
JOptionPane
的唯一方法。正在使用小程序。我对@user714965表示怀疑,认为您对实际尝试做的事情有第一个想法。@AndrewThompson@user714965:OP说他“对编程非常陌生”,所以他显然有很多东西要学。解释为什么他对自己所做的事情的想法是错误的会更有帮助。@iamnotmaynard“解释……会更有帮助”去做吧。我太忙了。这是JFrame。如果该点不可用,请使用null
。