📄 questionpanel.java
字号:
package gui;import paper.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.*;/** * @author SpiritRain * * abstract question panel * every question panel contains a single question * */public abstract class QuestionPanel extends JPanel { protected AbstractQuestion question; protected JPanel jPanelAns; protected JTextArea jTextAreaHint; protected JTextArea jTextAreaQuestion; protected JTextField jTextFieldAnsScore; protected JButton jButtonHint; protected boolean permit; public QuestionPanel(boolean permit) { this.permit = permit; this.setLayout(new BorderLayout()); jTextAreaHint = new JTextArea(); jTextAreaHint.setFocusable(permit); JScrollPane jScrollPaneHint = new JScrollPane(jTextAreaHint); JScrollPane jScrollPaneQ = new JScrollPane(jTextAreaQuestion = new JTextArea()); jTextAreaQuestion.setFocusable(permit); jTextFieldAnsScore = new JTextField(4); jTextFieldAnsScore.setEditable(permit); jTextFieldAnsScore.setFocusable(permit); jButtonHint = new JButton("Show Hints"); jButtonHint.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setHint(); } }); jPanelAns = new JPanel(); this.add(jScrollPaneHint, BorderLayout.NORTH); this.add(jScrollPaneQ, BorderLayout.CENTER); this.add(jPanelAns, BorderLayout.SOUTH); } protected void setQuestion(AbstractQuestion question) { this.question = question; jTextAreaQuestion.setText(question.getQuestionText()); if (permit){ this.jTextAreaHint.setText(question.getHint()); }else{ this.jTextAreaHint.setText(""); } } protected void setHint() { jTextAreaHint.setText(question.getHint()); } protected abstract AbstractQuestion createNewQuestion(int diff); protected abstract AbstractAnswer createNewAnswer(); protected abstract void setAnswer(AbstractAnswer ans);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -