1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| public class ExamJFrame extends JFrame{
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { ExamJFrame frame = new ExamJFrame(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
public ExamJFrame() { setTitle("标准化考试系统"); setBounds(100, 100, 660, 460); setVisible(true); welcomeLabel=new JLabel("欢迎考试,提高英语水平",JLabel.CENTER); list= new Choice(); String 当前目录=System.getProperty("user.dir"); File dir=new File(当前目录); displayarea = new JTextArea(15,12); displayarea.setLineWrap(true); displayarea.setWrapStyleWord(true); displayarea.setFont(new Font("TimesRoman",Font.PLAIN,14)); displayarea.setForeground(Color.blue); displayarea.setEnabled(false); messagearea=new JTextArea(8,8); messagearea.setForeground(Color.blue); messagearea.setLineWrap(true); messagearea.setWrapStyleWord(true); messagearea.setEnabled(false); choosePanel.add(chooseA); choosePanel.add(chooseB); choosePanel.add(chooseC); choosePanel.add(chooseD); timeShow=new JTextField(20); timeShow.setHorizontalAlignment(SwingConstants.RIGHT); timeShow.setEditable(false); timer=new JButton("暂停计时"); submmit=new JButton("提交该题答案"); next=new JButton("读取第一题"); next.setForeground(Color.blue); submmit.setForeground(Color.blue); viewscore=new JButton("查看分数"); viewscore.setForeground(Color.blue); submmit.setEnabled(false); readquestions=new ReadTestquestion(); Box boxH1=Box.createVerticalBox(), boxH2=Box.createVerticalBox(), baseBox=Box.createHorizontalBox(); boxH1.add(new JLabel("选择试题文件")); boxH1.add(list); boxH1.add(new JScrollPane(messagearea)); boxH1.add(viewscore); timeShow=new JTextField(20); timeShow.setHorizontalAlignment(SwingConstants.RIGHT); timeShow.setEditable(false); JPanel p1=new JPanel(); p1.add(new JLabel("剩余时间:")); p1.add(timeShow); p1.add(timer); boxH1.add(p1); boxH2.add(new JLabel("试题内容:")); boxH2.add(new JScrollPane(displayarea)); JPanel p2=new JPanel(); p2.add(choosePanel); p2.add(submmit); p2.add(next); boxH2.add(p2); baseBox.add(boxH1); baseBox.add(boxH2); setLayout(new BorderLayout()); add(baseBox,BorderLayout.CENTER); add(welcomeLabel,BorderLayout.NORTH); } }
|