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

📄 singlechoicejpanel.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.JButton;import javax.swing.ButtonGroup;import javax.swing.JOptionPane;import javax.swing.WindowConstants;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JRadioButton;import javax.swing.JTextArea;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 singleChoiceJPanel extends javax.swing.JPanel {	private JLabel itemtileLabel;	private JTextArea contentTextArea;	private JButton onsubmitButton;	private JRadioButton DRadioButton;	private JRadioButton CRadioButton;	private JRadioButton BRadioButton;	private JRadioButton ARadioButton;	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 singleChoiceJPanel());	//	frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);	//	frame.pack();	//	frame.setVisible(true);	//}		public singleChoiceJPanel(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()){			ARadioButton.setName("A");			ARadioButton.setText(stinfo.nextToken());		}		if(stinfo.hasMoreTokens()){			BRadioButton.setName("B");			BRadioButton.setText(stinfo.nextToken());		}		if(stinfo.hasMoreTokens()){			CRadioButton.setName("C");			CRadioButton.setText(stinfo.nextToken());		}		if(stinfo.hasMoreTokens()){			DRadioButton.setName("D");			DRadioButton.setText(stinfo.nextToken());		}	}		private void initGUI() {		try {			this.setPreferredSize(new java.awt.Dimension(500, 316));			this.setLayout(null);			{				itemtileLabel = new JLabel();				this.add(itemtileLabel);				itemtileLabel.setBounds(55, 46, 84, 23);			}			{				ARadioButton = new JRadioButton();				this.add(ARadioButton);								ARadioButton.setBounds(151, 104, 134, 18);			}			{				BRadioButton = new JRadioButton();				this.add(BRadioButton);								BRadioButton.setBounds(151, 141, 134, 18);			}			{				CRadioButton = new JRadioButton();				this.add(CRadioButton);								CRadioButton.setBounds(151, 180, 134, 18);			}			{				DRadioButton = new JRadioButton();				this.add(DRadioButton);								DRadioButton.setBounds(151, 216, 134, 18);			}			{				ButtonGroup group=new ButtonGroup();				group.add(ARadioButton);				group.add(BRadioButton);				group.add(CRadioButton);				group.add(DRadioButton);			}			{				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(ARadioButton.isSelected()){			answerstring+=ARadioButton.getName();			isanswer=true;		}		else if(BRadioButton.isSelected()){			answerstring+=BRadioButton.getName();			isanswer=true;		}		else if(CRadioButton.isSelected()){			answerstring+=CRadioButton.getName();			isanswer=true;		}		else if(DRadioButton.isSelected()){			answerstring+=DRadioButton.getName();			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,"请选择一个选项","联机测试系统",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 + -