⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 factualpanel.java

📁 考试系统
💻 JAVA
字号:
/*
 * Created on 2004-4-29
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import paper.*;

import javax.swing.*;

/**
 * @author SpiritRain
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class FactualPanel extends QuestionPanel {
	private JComponent jComponentAnswer;

	/**
	 * 
	 */
	public FactualPanel(boolean permit) {
		super(permit);
		jPanelAns.add(new JLabel("AbstractAnswer: "));
		if (permit){
			JComboBox jcb = new JComboBox();
			jComponentAnswer = new JComboBox();
			((JComboBox)jComponentAnswer).setEditable(true);
			jPanelAns.add(jComponentAnswer);
			JButton jButtonAdd = new JButton("Add AbstractAnswer");
			jButtonAdd.addActionListener(new ActionListener(){

				public void actionPerformed(ActionEvent arg0) {
					((JComboBox)jComponentAnswer).addItem(((JComboBox)jComponentAnswer).getSelectedItem());
					
				}});
			jPanelAns.add(jButtonAdd);
		}
		else{
			jComponentAnswer = new JTextField(20);
			jPanelAns.add(jComponentAnswer);
		}
		jPanelAns.add(new JLabel("Score:"));
		jPanelAns.add(jTextFieldAnsScore);

		jPanelAns.add(jButtonHint);
	}

	public AbstractAnswer createNewAnswer() {
		String[] str;
		if (permit){
			str = new String[((JComboBox)jComponentAnswer).getItemCount()];
			for (int i = 0; i < str.length ; i++){
				str[i] = (String)(((JComboBox)jComponentAnswer).getItemAt(i));
			}
		}
		else{
			str = new String[1];
			str[0] = ((JTextField)jComponentAnswer).getText();
		}
		AbstractAnswer ans = new FactualAns(str);
		return ans;
	}
	public void setAnswer(AbstractAnswer ans) {
		if (permit) {
			((JComboBox) jComponentAnswer).removeAllItems();
			if (ans == null) {
				((JTextField) jComponentAnswer).setText("");
			} else {
				for (int i = 0; i < ans.getAnsCount(); i++) {
					((JComboBox) jComponentAnswer).addItem(ans.getAnswer(i));
				}
			}
		} else {
			if (ans == null) {
				((JTextField) jComponentAnswer).setText("");
			} else {
				((JTextField) jComponentAnswer).setText(
					ans.getAnswer(0).toString());
			}
		}
		jTextFieldAnsScore.setText("" + question.getQuestionScore());
	}

	/* (non-Javadoc)
	 * @see gui.QuestionPanel#createNewQuestion()
	 */
	public AbstractQuestion createNewQuestion(int diff) {
		FactualASet fas = new FactualASet(createNewAnswer());
		FactualQuestion fq =
			new FactualQuestion(
				this.jTextAreaQuestion.getText(),
				fas,
				this.jTextAreaHint.getText(),
				Integer.parseInt(this.jTextFieldAnsScore.getText()),
				diff);
		return fq;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -