- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为学校开发一个 Java 编程项目。我需要设计一个 GUI,它将接受问题和答案并将它们存储在文件中。它应该能够包含无限数量的问题。我们已经介绍了二进制 I/O。
如何将他们提供的输入写入文件?我该如何让他们通过此 GUI 添加多个问题?
package multiplechoice;
import java.awt.*;
import javax.swing.*;
public class MultipleChoice extends JFrame {
public MultipleChoice() {
/*
* Setting Layout
*/
setLayout(new GridLayout(10,10));
/*
* First Question
*/
add(new JLabel("What is the category of the question?: "));
JTextField category = new JTextField();
add(category);
add(new JLabel("Please enter the question you wish to ask: "));
JTextField question = new JTextField();
add(question);
add(new JLabel("Please enter the correct answer: "));
JTextField correctAnswer = new JTextField();
add(correctAnswer);
add(new JLabel("Please enter a reccomended answer to display: "));
JTextField reccomendedAnswer = new JTextField();
add(reccomendedAnswer);
add(new JLabel("Please enter a choice for multiple choice option "
+ "A"));
JTextField A = new JTextField();
add(A);
add(new JLabel("Please enter a choice for multiple choice option "
+ "B"));
JTextField B = new JTextField();
add(B);
add(new JLabel("Please enter a choice for multiple choice option "
+ "C"));
JTextField C = new JTextField();
add(C);
add(new JLabel("Please enter a choice for multiple choice option "
+ "D"));
JTextField D = new JTextField();
add(D);
add(new JButton("Compile Questions"));
add(new JButton("Next Question"));
}
public static void main(String[] args) {
/*
* Creating JFrame to contain questions
*/
FinalProject frame = new FinalProject();
// FileOutputStream output = new FileOutputStream("Questions.dat");
JPanel panel = new JPanel();
// button.setLayout();
// frame.add(panel);
panel.setSize(100,100);
// button.setPreferredSize(new Dimension(100,100));
frame.setTitle("FinalProject");
frame.setSize(600, 400);
frame.setLocationRelativeTo(null); // Center the frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
最佳答案
在 Java 中写入文件基本上有两种方法。
Three or more; use a for.
这就是我在阅读 JTextField A = new JTextField();
和 JTextField B = new JTextField();
关于java - 带有问答系列的多项选择测试 GUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13427048/
I'm posting this in Q&A style as there are currently a few posts on S/O with similar questions and a
我正在尝试做一些我认为非常简单的事情——传递一个队列和一个函数,并将该函数应用于队列中的每个项目——但我无法编译它。 class Foo { public: void doStuff();
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 5 年前。 Improve th
我的密码使用的是 sha512,但 secret 问题和答案是纯文本。问题是:我需要散列 secret 答案吗?如果是这样,它使用什么数据类型,它仍然是 char(128) 吗?我假设 secret
以前是否有人使用 Freebase 作为知识库在问答机上做过任何工作?我在网上搜索了这个,但没有得到任何实质性的东西。有谁知道在输入非结构化问题并且 QA 引擎利用 Freebase 提供答案的这个领
以前是否有人使用 Freebase 作为知识库在问答机上做过任何工作?我在网上搜索了这个,但没有得到任何实质性的东西。有谁知道在输入非结构化问题并且 QA 引擎利用 Freebase 提供答案的这个领
我正在尝试编写一个您自己的时区转换器,我需要一种方法来确定该月的最后一天可能是哪一天。经过一些研究,我发现了寻找闰年的公式。 这是一个很小的贡献,但也许我会为其他人节省我花 20 分钟弄清楚并应用它的
我有一个 Azure Function(不在容器中)。 当我将其发布到本地 Azure 时,就可以了。 当我从 Azure Devops 发布它时,部署成功,但该函数无法运行。错误“Azure 函数运
当 __getitem__ 映射到内部序列类型时,以下哪一项是推荐的执行方式? class A: def __init__(self, ...): ... se
如何在我的 ng2 应用程序中使用预处理器?我正在使用 angular-cli 和 the original docs对我来说还不够清楚。此外,我想在全局范围内使用这些样式,而不仅仅是在组件范围内。
StackO 的 friend 们大家好。 最后一天,我研究了一种解决方案,将不同表中的特定值导出到一个 XML 文件中。主要问题:我有三层嵌套表。由于我在编写这些函数时遇到了问题,因此我想与您分享我
这是一个问答,这意味着我正在分享我对我遇到的问题的解决方案/答案: 问题是 getting started guide来自 apache 站点的并不完全是最新的,经过一些摆弄之后,我设法让示例工作。
我是一名优秀的程序员,十分优秀!