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

📄 truefalsejpanel.java

📁 连接测试系统
💻 JAVA
字号:
package com.cnu.cie.olts.client;import java.awt.Dimension;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.StringTokenizer;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JRadioButton;import javax.swing.JTextArea;import javax.swing.WindowConstants;import javax.swing.JFrame;import com.cnu.cie.olts.client.student.StudentFrame;import com.cnu.cie.olts.client.teacher.TeacherFrame;/*** This code was edited or generated using CloudGarden's Jigloo* SWT/Swing GUI Builder, which is free for non-commercial* use. If Jigloo is being used commercially (ie, by a corporation,* company or business for any purpose whatever) then you* should purchase a license for each developer using Jigloo.* Please visit www.cloudgarden.com for details.* Use of Jigloo implies acceptance of these licensing terms.* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.*/public class TrueFalseJPanel extends javax.swing.JPanel {	private JLabel itemtileLabel;	private JTextArea contentTextArea;	private JButton onsubmitButton;	private JRadioButton TrueRadioButton;	private JRadioButton FalseRadioButton;	private ItemInfo iteminfo;	/**	* Auto-generated main method to display this 	* JPanel inside a new JFrame.	*//*	public static void main(String[] args) {		JFrame frame = new JFrame();		frame.getContentPane().add(new TrueFalseJPanel());		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);		frame.pack();		frame.setVisible(true);	}	*/	public TrueFalseJPanel(ItemInfo iteminfo) {		super();		initGUI();		this.iteminfo=iteminfo;		itemtileLabel.setText(iteminfo.itemtype);		StringTokenizer stinfo=new StringTokenizer(iteminfo.content,"#_#"); 		contentTextArea.setText(stinfo.nextToken()+"(分值:"+iteminfo.score+")");		if(stinfo.hasMoreTokens()){			TrueRadioButton.setText(stinfo.nextToken());		}		if(stinfo.hasMoreTokens()){			FalseRadioButton.setText(stinfo.nextToken());		}	}		private void initGUI() {		try {			setPreferredSize(new Dimension(500, 316));			this.setLayout(null);			{				itemtileLabel = new JLabel();				this.add(itemtileLabel);				itemtileLabel.setBounds(55, 46, 84, 23);			}			{				TrueRadioButton = new JRadioButton();				this.add(TrueRadioButton);								TrueRadioButton.setBounds(151, 142, 80, 25);			}			{				FalseRadioButton = new JRadioButton();				this.add(FalseRadioButton);								FalseRadioButton.setBounds(263, 142, 81, 25);			}			{				ButtonGroup group=new ButtonGroup();				group.add(TrueRadioButton);				group.add(FalseRadioButton);			}			{				onsubmitButton = new JButton();				this.add(onsubmitButton);				onsubmitButton.setText("\u63d0\u4ea4");				onsubmitButton.setBounds(178, 261, 85, 28);				onsubmitButton.addActionListener(new ActionListener() {					public void actionPerformed(ActionEvent evt) {						onsubmitButtonActionPerformed(evt);					}				});			}			{				contentTextArea = new JTextArea();				this.add(contentTextArea);					contentTextArea.setEditable(false);				contentTextArea.setBounds(151, 35, 325, 51);			}		} catch (Exception e) {			e.printStackTrace();		}	}		private void onsubmitButtonActionPerformed(ActionEvent evt) {		//System.out.println("onsubmitButton.actionPerformed, event="+evt);		//TODO add your code for onsubmitButton.actionPerformed		boolean isanswer=false;		String answerstring="";		if(TrueRadioButton.isSelected()){			answerstring+=TrueRadioButton.getText();			isanswer=true;		}		else if(FalseRadioButton.isSelected()){			answerstring+=FalseRadioButton.getText();			isanswer=true;		}				if(isanswer){			if(answerstring.equals(iteminfo.answer))				StudentFrame.testscore+=iteminfo.score;			else				JOptionPane.showMessageDialog(null,"正确选项:"+iteminfo.answer,"联机测试系统",JOptionPane.INFORMATION_MESSAGE);		}		else {			JOptionPane.showMessageDialog(null,"请选择一个选项","ERROR",JOptionPane.ERROR_MESSAGE);			return;		}				String statusstring=Login.status;		if("学生".equals(statusstring))			StudentFrame.NextItem();		else if("教师".equals(statusstring))			TeacherFrame.NextItem();	}}

⌨️ 快捷键说明

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