英语四六级考试系统计算机考试系统试题可定制的各科考试系统软件java开发.docx
《英语四六级考试系统计算机考试系统试题可定制的各科考试系统软件java开发.docx》由会员分享,可在线阅读,更多相关《英语四六级考试系统计算机考试系统试题可定制的各科考试系统软件java开发.docx(20页珍藏版)》请在冰豆网上搜索。
英语四六级考试系统计算机考试系统试题可定制的各科考试系统软件java开发
packagecom.mingrui.english;
importjava.awt.*;
importjava.awt.event.*;
importjava.io.BufferedReader;
importjava.io.File;
importjava.io.FileNotFoundException;
importjava.io.FileReader;
importjava.io.IOException;
importjava.io.PrintWriter;
importjava.text.SimpleDateFormat;
importjava.util.Date;
importjava.util.Scanner;
importjavax.swing.*;
importjavax.swing.border.Border;
importjavax.swing.border.TitledBorder;
importjavax.swing.event.TableModelListener;
importjavax.swing.table.DefaultTableModel;
importjavax.swing.table.TableModel;
publicclassMyTestextendsJFrame{
/**
*
*/
privatestaticfinallongserialVersionUID=1L;
/**
*@paramargs
*/
JComboBoxjcbPaper;
JComboBoxjcbAnswer;
JTextAreajta=newJTextArea("-----------------------------------------------------------",100,60);
JTabletableChose=newJTable();
JTabletableFinal=newJTable();
TableChoseModeltcm=newTableChoseModel();
TableFinalModeltfm=newTableFinalModel();
JPaneljpdown=newJPanel();
JPaneljpleft=newJPanel();
JLabellabicon=newJLabel(newImageIcon("img/mm.jpg"));
JLabellabicon1=newJLabel(newImageIcon("img/mm.jpg"));
JSplitPanesplitpane;
JSplitPanesplitpanewhole;
Borderborder=newTitledBorder("题目区:
");
Borderborder1=newTitledBorder("答题区:
");
Borderborder2=newTitledBorder("功能区:
");
JButtonjbconfirm=newJButton("提交答案",newImageIcon("img/7.gif"));
JButtonjbanaly=newJButton("分析一下",newImageIcon("img/68.png"));
JButtonjbsave=newJButton("保存到文件",newImageIcon("img/80.png"));
JButtonjbanswer=newJButton("看看答案",newImageIcon("img/155.png"));
JLabeljlshowtime=newJLabel("现在时间是:
0000-00-0000:
00:
00");
JLabeljlchosepaper=newJLabel("请选择你要答题的试卷:
");
JLabeljltimeremain=newJLabel("剩余时间是:
00:
00:
00");
Stringstr="";
inttotaltime=30*60*1000;
intdaan=10;
MyTest(){
setSize(1280,700);
setLocationRelativeTo(null);
setDefaultCloseOperation(3);
setResizable(true);
jta.setBackground(newColor(16766274));
jpdown.setBackground(newColor(14172199));
jltimeremain.setBackground(Color.orange);
jbconfirm.setBackground(newColor(12514438));
Timertimer=newTimer(1000,newActionListener()
{
publicvoidactionPerformed(ActionEvente)
{
str=newSimpleDateFormat("yyyy-MM-ddHH:
mm:
ss").format(newDate());
jlshowtime.setText("现在时间是:
"+str);
totaltime-=1000;
Datedateremain=newDate(totaltime);
inthour=totaltime/(1000*60*60);
intmin=totaltime/(1000*60);
intsec=totaltime%(1000*60);
jltimeremain.setText("剩余时间是:
"+hour+":
"+min+":
"+sec);
if(totaltime==0)
JOptionPane.showMessageDialog(null,"时间到,请停止答题");
}
});
timer.start();
jcbPaper=newJComboBox<>(newString[]{"2012年六月","2012年十二月","2011年六月","2011年十二月",
"2010年六月","2010年十二月","2009年六月","2009年十二月","2008年六月","2008年十二月"});
jcbPaper.addItemListener(newItemListener(){
@Override
publicvoiditemStateChanged(ItemEvente){
//TODOAuto-generatedmethodstub
if(e.getItem()=="2012年十二月"){
Filef=newFile("ti/1.ti");
jta.setText("2012年十二月");
daan=1;
try{
Scannerscan=newScanner(f);
while(scan.hasNextLine()){
Stringstrf=scan.nextLine();
jta.append(strf+"\r\n");
}
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
elseif(e.getItem()=="2011年六月"){
Filef=newFile("ti/2.ti");
jta.setText("2010年6月");
daan=2;
try{
Scannerscan=newScanner(f);
while(scan.hasNextLine()){
Stringstrf=scan.nextLine();
jta.append(strf+"\r\n");
}
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
elseif(e.getItem()=="2011年十二月"){
Filef=newFile("ti/3.ti");
jta.setText("2010年12月");
daan=3;
try{
Scannerscan=newScanner(f);
while(scan.hasNextLine()){
Stringstrf=scan.nextLine();
jta.append(strf+"\r\n");
}
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
elseif(e.getItem()=="2010年六月"){
Filef=newFile("ti/4.ti");
jta.setText("2010年6月");
daan=4;
try{
Scannerscan=newScanner(f);
while(scan.hasNextLine()){
Stringstrf=scan.nextLine();
jta.append(strf+"\r\n");
}
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
elseif(e.getItem()=="2010年十二月"){
Filef=newFile("ti/5.ti");
jta.setText("2010年12月");
daan=5;
try{
Scannerscan=newScanner(f);
while(scan.hasNextLine()){
Stringstrf=scan.nextLine();
jta.append(strf+"\r\n");
}
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
elseif(e.getItem()=="2009年六月"){
Filef=newFile("ti/6.ti");
jta.setText("2009年6月");
daan=6;
try{
Scannerscan=newScanner(f);
while(scan.hasNextLine()){
Stringstrf=scan.nextLine();
jta.append(strf+"\r\n");
}
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
elseif(e.getItem()=="2009年十二月"){
Filef=newFile("ti/7.ti");
jta.setText("2009年12月");
daan=7;
try{
Scannerscan=newScanner(f);
while(scan.hasNextLine()){
Stringstrf=scan.nextLine();
jta.append(strf+"\r\n");
}
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
elseif(e.getItem()=="2008年六月"){
Filef=newFile("ti/8.ti");
jta.setText("2008年6月");
daan=8;
try{
Scannerscan=newScanner(f);
while(scan.hasNextLine()){
Stringstrf=scan.nextLine();
jta.append(strf+"\r\n");
}
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
elseif(e.getItem()=="2008年十二月"){
Filef=newFile("ti/9.ti");
jta.setText("2008年12月");
daan=9;
try{
Scannerscan=newScanner(f);
while(scan.hasNextLine()){
Stringstrf=scan.nextLine();
jta.append(strf+"\r\n");
}
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
else{
Filef=newFile("ti/10.ti");
jta.setText("2012年6月");
daan=10;
try{
Scannerscan=newScanner(f);
while(scan.hasNextLine()){
Stringstrf=scan.nextLine();
jta.append(strf+"\r\n");
}
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
}
});
jcbAnswer=newJComboBox<>(newString[]{"A","B","C","D"});
jcbPaper.setBackground(newColor(12514438));
jta.setSize(600,650);
jta.setLineWrap(true);
jta.setWrapStyleWord(true);
jta.setBorder(border);
tableChose.setModel(tcm);
tableFinal.setModel(tfm);
tableChose.getColumnModel().getColumn(5).setCellEditor(newDefaultCellEditor(jcbAnswer));
splitpane=newJSplitPane(JSplitPane.HORIZONTAL_SPLIT,newJScrollPane(jta),newJScrollPane(tableChose));
splitpane.setBorder(border1);
splitpane.setBackground(newColor(15453926));
tableChose.setBackground(newColor(244447));
add(splitpane,BorderLayout.CENTER);
//add(jpup,BorderLayout.CENTER);
jpdown.setLayout(newGridLayout(1,5));
jpdown.add(jlchosepaper);
jpdown.add(jcbPaper);
jpdown.add(jlshowtime);
jpdown.add(jltimeremain);
jpdown.add(jbconfirm);
add(jpdown,BorderLayout.SOUTH);
tableFinal.setSize(200,300);
//jpleft.add(newJScrollPane(tableFinal),BorderLayout.CENTER);
jbsave.setBackground(newColor(4322213));
jbanaly.setBackground(newColor(4322213));
jbanswer.setBackground(newColor(4322213));
jbanswer.addActionListener(newActionListener(){
@Override
publicvoidactionPerformed(ActionEvente){
//TODOAuto-generatedmethodstub
try{
newAnswerGui(daan);
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
});
jbconfirm.addActionListener(newActionListener(){
@Override
publicvoidactionPerformed(ActionEvente){
Filefdaan=newFile("reso/"+daan+".res");
try{
//Scannerscan=newScanner(fdaan);
BufferedReaderbr=newBufferedReader(newFileReader(fdaan));
Stringstr=br.readLine();
Stringstrn[]=str.split("");
intcountm=0;
//char[]buf=newchar[10];
for(inti=0;i<7;i++){
if(tableChose.getValueAt(i,5)!
=null&&tableChose.getValueAt(i,5).equals(strn[i].trim()))
countm++;
}
for(inti=0;i<25;i++){
if(tableChose.getValueAt(i+10,5)!
=null&&tableChose.getValueAt(i+10,5).equals(strn[i+7].trim()))
countm++;
}
for(inti=0;i<10;i++){
if(tableChose.getValueAt(i+51,5)!
=null&&tableChose.getValueAt(i+51,5).equals(strn[i+32].trim()))
countm++;
}
for(inti=0;i<20;i++){
if(tableChose.getValueAt(i+61,5)!
=null&&tableChose.getValueAt(i+61,5).equals(strn[i+42].trim()))
countm++;
}
JOptionPane.showMessageDialog(null,"一共答对了"+countm+"道题");
}catch(FileNotFoundExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}catch(IOExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
});
jbsa