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

📄 exammainframe.java

📁 这是一个很好的考试系统的源码
💻 JAVA
字号:
package com.tarena.exam.gui;import java.awt.Dimension;import java.awt.Font;import java.awt.Point;import java.awt.Rectangle;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.JTextArea;import javax.swing.SwingConstants;public class ExamMainFrame extends JFrame implements ActionListener{	private static final long serialVersionUID = 1L;	private JPanel jContentPane = null;	private JLabel jLabel = null;	private JLabel jLabel1 = null;	private JLabel jLabel2 = null;	private JLabel jLabel3 = null;	private JLabel studentName = null;//显示学生姓名的Label	private JLabel studentID = null;//显示学生ID的Label	private JLabel subject = null;//显示科目名称的Label	private JTextArea jTextArea = null;//显示试题的文本框	private JRadioButton aRadio = null;//A选项按钮	private JRadioButton bRadio = null;//B选项按钮	private JRadioButton cRadio = null;//C选项按钮	private JRadioButton dRadio = null;//D选项按钮	private JButton previous = null;//上一题按钮	private JButton next = null;//下一题按钮	private JButton handIn = null;//交卷按钮	private JLabel jLabel7 = null;	private JLabel jLabel8 = null;	private JLabel remainQuestions = null;//显示剩余试题数的Label	private JLabel remainTime = null;//显示剩余时间的Label	/**	 * This method initializes jTextArea		 * 		 * @return javax.swing.JTextArea		 */	private JTextArea getJTextArea() {		if (jTextArea == null) {			jTextArea = new JTextArea();			jTextArea.setBounds(new Rectangle(14, 75, 738, 269));		}		return jTextArea;	}	/**	 * This method initializes aRadio		 * 		 * @return javax.swing.JRadioButton		 */	private JRadioButton getARadio() {		if (aRadio == null) {			aRadio = new JRadioButton();			aRadio.setPreferredSize(new Dimension(35, 30));			aRadio.setSize(new Dimension(50, 25));			aRadio.setLocation(new Point(262, 367));			aRadio.setText("A");		}		return aRadio;	}	/**	 * This method initializes bRadio		 * 		 * @return javax.swing.JRadioButton		 */	private JRadioButton getBRadio() {		if (bRadio == null) {			bRadio = new JRadioButton();			bRadio.setPreferredSize(new Dimension(35, 30));			bRadio.setSize(new Dimension(50, 25));			bRadio.setLocation(new Point(322, 367));			bRadio.setText("B");		}		return bRadio;	}	/**	 * This method initializes cRadio		 * 		 * @return javax.swing.JRadioButton		 */	private JRadioButton getCRadio() {		if (cRadio == null) {			cRadio = new JRadioButton();			cRadio.setText("C");			cRadio.setLocation(new Point(382, 367));			cRadio.setSize(new Dimension(50, 25));		}		return cRadio;	}	/**	 * This method initializes dRadio		 * 		 * @return javax.swing.JRadioButton		 */	private JRadioButton getDRadio() {		if (dRadio == null) {			dRadio = new JRadioButton();			dRadio.setText("D");			dRadio.setLocation(new Point(442, 367));			dRadio.setSize(new Dimension(50, 25));		}		return dRadio;	}	/**	 * This method initializes previous		 * 		 * @return javax.swing.JButton		 */	private JButton getPrevious() {		if (previous == null) {			previous = new JButton();			previous.setText("<< 上一题");			previous.setLocation(new Point(220, 412));			previous.setSize(new Dimension(90, 35));		}		return previous;	}	/**	 * This method initializes next		 * 		 * @return javax.swing.JButton		 */	private JButton getNext() {		if (next == null) {			next = new JButton();			next.setText("下一题 >>");			next.setLocation(new Point(350, 412));			next.setSize(new Dimension(90, 35));		}		return next;	}	/**	 * This method initializes handIn		 * 		 * @return javax.swing.JButton		 */	private JButton getHandIn() {		if (handIn == null) {			handIn = new JButton();			handIn.setText("交卷");			handIn.setSize(new Dimension(90, 35));			handIn.setLocation(new Point(470, 412));		}		return handIn;	}		/**	 * 为图形组件添加事件的方法	 */	public void addEventHandler(){		handIn.addActionListener(this);		previous.addActionListener(this);		next.addActionListener(this);					}		public void showMe(){		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);		this.setVisible(true);		new TimeRefreshThread().start();	}			class TimeRefreshThread extends Thread{		public void run(){			//???		}	}			/**	 * 本类实现ActionListener,实现actionPerformed方法	 */	public void actionPerformed(ActionEvent e) {		String str=e.getActionCommand();		if(str.equals("交卷")){			//????						return;		}				if(str.equals("<<上一题")){			//????						return;		}				if(str.equals("下一题>>")){			//????						return;		}							}	/**	 * @param args	 */	public static void main(String[] args) {		new ExamMainFrame().showMe();	}	/**	 * This is the default constructor	 */	public ExamMainFrame() {		super();		initialize();	}	/**	 * This method initializes this	 * 	 * @return void	 */	private void initialize() {		this.setSize(775, 515);		this.setContentPane(getJContentPane());		this.setTitle("JFrame");	}	/**	 * This method initializes jContentPane	 * 	 * @return javax.swing.JPanel	 */	private JPanel getJContentPane() {		if (jContentPane == null) {			remainTime = new JLabel();			remainTime.setBounds(new Rectangle(644, 393, 106, 36));			remainTime.setText("");			remainQuestions = new JLabel();			remainQuestions.setBounds(new Rectangle(25, 396, 107, 35));			remainQuestions.setText("");			jLabel8 = new JLabel();			jLabel8.setBounds(new Rectangle(643, 372, 98, 21));			jLabel8.setText("剩余时间:");			jLabel7 = new JLabel();			jLabel7.setBounds(new Rectangle(24, 373, 94, 23));			jLabel7.setText("剩余试题:");			subject = new JLabel();			subject.setBounds(new Rectangle(531, 46, 85, 19));			subject.setText("");			studentID = new JLabel();			studentID.setBounds(new Rectangle(378, 47, 79, 18));			studentID.setText("");			studentName = new JLabel();			studentName.setBounds(new Rectangle(226, 45, 80, 19));			studentName.setText("");			jLabel3 = new JLabel();			jLabel3.setBounds(new Rectangle(150, 45, 77, 19));			jLabel3.setText("考生姓名:");			jLabel2 = new JLabel();			jLabel2.setBounds(new Rectangle(314, 46, 65, 19));			jLabel2.setText("考生编号:");			jLabel1 = new JLabel();			jLabel1.setBounds(new Rectangle(468, 46, 64, 19));			jLabel1.setText("考试科目:");			jLabel = new JLabel();			jLabel.setBounds(new Rectangle(172, 4, 415, 33));			jLabel.setFont(new Font("Dialog", Font.BOLD, 24));			jLabel.setHorizontalAlignment(SwingConstants.CENTER);			jLabel.setText("欢迎进入达内标准化考试系统");			jContentPane = new JPanel();			jContentPane.setLayout(null);			jContentPane.add(jLabel, null);			jContentPane.add(jLabel1, null);			jContentPane.add(jLabel2, null);			jContentPane.add(jLabel3, null);			jContentPane.add(studentName, null);			jContentPane.add(studentID, null);			jContentPane.add(subject, null);			jContentPane.add(getJTextArea(), null);			jContentPane.add(getARadio(), null);			jContentPane.add(getBRadio(), null);			jContentPane.add(getCRadio(), null);			jContentPane.add(getDRadio(), null);			jContentPane.add(getPrevious(), null);			jContentPane.add(getNext(), null);			jContentPane.add(getHandIn(), null);			jContentPane.add(jLabel7, null);			jContentPane.add(jLabel8, null);			jContentPane.add(remainQuestions, null);			jContentPane.add(remainTime, null);		}		return jContentPane;	}}  //  @jve:decl-index=0:visual-constraint="18,21"

⌨️ 快捷键说明

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