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

📄 englishtest2.java

📁 模拟在线考试系统
💻 JAVA
字号:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.net.*;



public class EnglishTest2  implements ActionListener,Runnable
  {
  	     JFrame JF;
         static JTextArea messageArea,questionArea;
          JButton button=new JButton("提交答案");
          JButton button1=new JButton("查看成绩");
          JPanel p2;
          Socket socket1;
          JCheckBox box[];
          Container con;
         static PrintWriter out;
         static BufferedReader in;
         static Thread t;
       
         static int counter;
          
           public EnglishTest2(Socket ss) 
              {
              		socket1=ss;
              }
          public EnglishTest2()
          
               {
               		
                   JF=new JFrame();
                   JF.setBounds(60,40,660,460);
                questionArea=new JTextArea(12,5);
              
                questionArea.setFont(new Font("TimesRoman",Font.PLAIN,14));
                questionArea.setForeground(Color.blue);
                messageArea=new JTextArea(18,25);
                messageArea.setForeground(Color.blue);
                messageArea.setLineWrap(true);
                messageArea.setWrapStyleWord(true);


                Box boxh1=Box.createVerticalBox(),	boxh2=Box.createVerticalBox(),basebox=Box.createHorizontalBox();
                boxh1.add(new JLabel("试题内容"));

                boxh1.add(new JScrollPane(messageArea));
                boxh2.add(new JLabel("答题区 答案写完后 以#结束"));
                boxh2.add(new JScrollPane(questionArea));
                p2=new JPanel();
                p2.add(button);
                p2.add(button1);
          
                boxh2.add(p2);
                basebox.add(boxh1);
                basebox.add(boxh2);
                JF.getContentPane().setLayout(new BorderLayout());
                JF.getContentPane().add(basebox,BorderLayout.CENTER);
                button.addActionListener(this);
                button1.addActionListener(this);
                JF.show();

             }
             
             
             
              public static void main(String args[])
               {
                 new EnglishTest2();
                try
                {
                 Socket socket=new Socket("127.0.0.1",1680);
                 t=new Thread(new EnglishTest2(socket));
                 t.start();
                 
                 }catch (Exception e1){System.out.print("在第1个try处有异常");}
                

               }
               public void run()
               {
               //	int mynum=++Num;
               	try
               	{
               	 out=new PrintWriter(socket1.getOutputStream());
                 in=new BufferedReader(new InputStreamReader(socket1.getInputStream()));
                 String s;
                 do
                 {
                 	s=in.readLine();
                    messageArea.append("\n"+ s);
                 	
                 }while(!s.equals("endend"));
                 
                  messageArea.append("\n"+ "试题发送完毕 开始答卷");	
                  
                  	
               	}catch (Exception e2){System.out.print("在第2个try处有异常");}
               	
               	
               }
             public void actionPerformed(ActionEvent e)
             {
             
             	if (e.getActionCommand()=="提交答案")
             	{
             	
             		    String ss;
             	
             			ss=questionArea.getText();
             		    out.println(ss);
             		   
             	        out.flush();
             	
             	}
             	
             	
             	else if(e.getActionCommand()=="查看成绩")
             	{
             	  
             	   
             	   try
             	   {
             	    counter=Integer.parseInt(in.readLine());
                  
                    questionArea.setText("\n"+"你的得分是:"+ counter);
             	  }catch(IOException e3 ){}
             
             

             }

             }
}
  



⌨️ 快捷键说明

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