简体   繁体   English

Java(NetBeans)中的多个PanCard中的多个复选框的侦听器

[英]Listener for Multiple checkboxes in multiple PanCards in Java (NetBeans)

I'm trying to make a Quizz, and I've created multiple PanCards(15), each having a question and 4 answers (radio buttons or check boxes or text fields) and I'm trying to export what the user clicks/introduces in a *.txt file. 我正在尝试进行Quizz,并且创建了多个PanCard(15),每个PanCard都有一个问题和4个答案(单选按钮,复选框或文本字段),并且尝试导出用户单击/引入的内容在* .txt文件中。 Is there any method to do it more quick? 有什么方法可以更快地做到吗? Or I should create an eventListener for each question and if the checkboxes are selected, I'll write them separately. 或者,我应该为每个问题创建一个eventListener,如果选中了复选框,我将分别编写它们。 I can't figure out how am I supposed to know how many checkboxes will going to be selected, since each pan has 4 checkboxes from which the user can select from 0 to 4 answers and the radio buttons are grouped as buttonGroup(1,2,7,8,13) 我不知道应该怎么知道要选择多少个复选框,因为每个平底锅都有4个复选框,用户可以从中选择0到4个答案,并且单选按钮被分组为buttonGroup(1,2 ,7,8,13)

So, I can't do something like this: for (int i=0; i 因此,我无法执行以下操作:for(int i = 0; i

Any ideas? 有任何想法吗?

I don't think you need eventlisteners for every element. 我认为您不需要每个元素都使用事件监听器。 The way I see it you don't want the info about the checkboxes/text fields when the user just filled them in. You should just check the status of your checkboxes and textfields when the user is done with the specific quiz question, which is when for example the user presses a button labeled "Next question". 我的查看方式是,您不希望在用户填写复选框/文本字段时获得有关这些信息的信息。当用户完成特定测验问题后,您应该只检查复选框和文本字段的状态,即例如,当用户按下标有“下一个问题”的按钮时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM