📄 fillblankjpanel.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.JCheckBox;import javax.swing.JLabel;import javax.swing.JOptionPane;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 FillBlankJPanel extends javax.swing.JPanel { private JLabel itemtileLabel; private JLabel answerLabel; private JTextArea answerTextArea; private JTextArea contentTextArea; private JButton onsubmitButton; 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 FillBlankJPanel()); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.pack(); frame.setVisible(true); } */ public FillBlankJPanel(ItemInfo iteminfo) { super(); initGUI(); this.iteminfo=iteminfo; itemtileLabel.setText(iteminfo.itemtype); contentTextArea.setText(iteminfo.content+"(分值:"+iteminfo.score+")"); contentTextArea.setEditable(false); answerLabel.setText("答题区"); } private void initGUI() { try { setPreferredSize(new Dimension(500, 316)); this.setLayout(null); { itemtileLabel = new JLabel(); this.add(itemtileLabel); itemtileLabel.setBounds(55, 46, 84, 23); } { 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); } { answerTextArea = new JTextArea(); this.add(answerTextArea); answerTextArea.setBounds(151, 118, 325, 106); } { answerLabel = new JLabel(); this.add(answerLabel); answerLabel.setBounds(55, 128, 78, 23); } } catch (Exception e) { e.printStackTrace(); } } private void onsubmitButtonActionPerformed(ActionEvent evt) { //System.out.println("onsubmitButton.actionPerformed, event="+evt); //TODO add your code for onsubmitButton.actionPerformed String answerstring=answerTextArea.getText().trim(); if(answerstring!=null&&!answerstring.equals("")){ 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 + -