// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: dccj.java
//coded by lengping
//all right reserved
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.*;
import java.io.PrintStream;
import java.util.LinkedList;
import java.util.Calendar;
import javax.swing.*;
public class Dcdb extends MyDialog
{
JLabel lword;
JLabel ltip;
JLabel l1;
JLabel l2;
JLabel l3;
JLabel l4;
int icount;
int iright;
int ianswer;
int ichoice;
int iresult;
boolean bwait;
JLabel lall[];
JLabel lpic[] = {
new JLabel(""), new JLabel(""), new JLabel(""), new JLabel("")
};
static Icon icon1 = new ImageIcon("selected.gif");
static Icon icon2 = new ImageIcon("bingle.gif");
static Icon icon3 = new ImageIcon("right.gif");
static Icon icon4 = new ImageIcon("wrong.gif");
static Icon iconsymbol;
LinkedList ll1;
LinkedList ll2;
Db db1;
Studylog sl=new Studylog();
ActionListener al=new ActionListener(){
public void actionPerformed(ActionEvent actionevent)
{
if(iright >= Person.wordspg)
end();
else
nextword();
timer.stop();
timer2.stop();
bwait = false;
}
};
Timer timer;
Timer timer2;
KeyListener kl=new KeyListener(){
public void keyPressed(KeyEvent keyevent)
{
//System.out.println("keyPressed" + keyevent.paramString() + keyevent.getKeyChar());
switch(keyevent.getKeyCode())
{
default:
break;
case 40: // '('
if(!bwait && ichoice != 3)
{
ichoice++;
setChoice();
}
break;
case 38: // '&'
if(!bwait && ichoice != 0)
{
ichoice--;
setChoice();
}
break;
case 10: // '\n'
case 32: // ' '
postSelection();
break;
}
}
public void keyReleased(KeyEvent keyevent){}
public void keyTyped(KeyEvent keyevent){}
};//end kl
public Dcdb(JFrame jframe)
{
super(jframe, "单词测试", true);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowevent)
{
timer.stop();
timer2.stop();
dispose();
}
});
lword = new JLabel(" ");
ltip = new JLabel("");
l1 = new JLabel(" ");
l2 = new JLabel(" ");
l3 = new JLabel(" ");
l4 = new JLabel(" ");
bwait = false;
lall = (new JLabel[] {
l1, l2, l3, l4
});
ll1 = new LinkedList();
ll2 = new LinkedList();
db1 = new Db();
al = new ActionListener() {
public void actionPerformed(ActionEvent actionevent)
{
if(iright >= Person.wordspg)
end();
else
nextword();
timer.stop();
timer2.stop();
bwait = false;
}
};
timer = new Timer(500, al);
timer2 = new Timer(2000, al);
kl = new KeyListener() {
public void keyPressed(KeyEvent keyevent)
{
System.out.println("keyPressed" + keyevent.paramString() + keyevent.getKeyChar());
switch(keyevent.getKeyCode())
{
default:
break;
case 40: // '('
if(!bwait && ichoice != 3)
{
ichoice++;
setChoice();
}
break;
case 38: // '&'
if(!bwait && ichoice != 0)
{
ichoice--;
setChoice();
}
break;
case 10: // '\n'
case 32: // ' '
postSelection();
break;
}
}
public void keyReleased(KeyEvent keyevent)
{
}
public void keyTyped(KeyEvent keyevent)
{
}
};
addKeyListener(kl);
Container container = getContentPane();
setSize(500, 400);
container.setLayout(new GridLayout(5, 2));
lword.setHorizontalAlignment(4);
container.add(lword);
ltip.setHorizontalAlignment(4);
container.add(ltip);
//phonetic symbol
lpic[0].setHorizontalAlignment(4);
lpic[1].setHorizontalAlignment(4);
lpic[2].setHorizontalAlignment(4);
lpic[3].setHorizontalAlignment(4);
container.add(lpic[0]);
container.add(l1);
container.add(lpic[1]);
container.add(l2);
container.add(lpic[2]);
container.add(l3);
container.add(lpic[3]);
container.add(l4);
setCenter();
init();
}
void init()
{
db1.setwordspg(Person.wordspg);
db1.getGroup(ll1, Person.dcdbgroup);
if(Person.dcdbgroup + 2 > Person.maxgroup)
db1.getGroup(ll2, Person.dcdbgroup - 2);
else
db1.getGroup(ll2, Person.dcdbgroup + 2);
setTitle("单词测试-第" + Person.dcdbgroup + "组");
icount = -1;
iright = 0;
iresult=0;
ltip.setText("开始了! ");
nextword();
}
void postSelection()
{
if(ichoice == ianswer)
{
iright++;
Word word = (Word)ll1.get(icount);
word.tag = 1;
lpic[ianswer].setIcon(icon2);
timer.start();
} else
{
lpic[ianswer].setIcon(icon3);
lpic[ichoice].setIcon(icon4);
timer2.start();
}
bwait = true;
ltip.setText("做对了" + iright + "个单词");
}
void nextword()
{
icount++;
if(icount == Person.wordspg){
icount = 0;
iresult=iright;
}
for(Word word = (Word)ll1.get(icount); word.tag == 1; word = (Word)ll1.get(icount))
{
icount++;
if(icount == Person.wordspg)
icount = 0;
}
int i = (int)(Math.random() * (double)Person.wordspg);
Word word1 = (Word)ll2.get(i);
l1.setText(word1.zs);
i = (int)(Math.random() * (double)Person.wordspg);
word1 = (Word)ll2.get(i);
l2.setText(word1.zs);
i = (int)(Math.random() * (double)Person.wordspg);
word1 = (Word)ll2.get(i);
l3.setText(word1.zs);
i = (int)(Math.random() * (double)Person.wordspg);
word1 = (Word)ll2.get(i);
l4.setText(word1.zs);
//current word
word1 = (Word)ll1.get(icount);
lword.setText(word1.dc);
ianswer = (int)(Math.random() * 4D);
lall[ianswer].setText(word1.zs);
//symbol
iconsymbol=new ImageIcon(Symbol.getImage(word1.yb));
ltip.setIcon(iconsymbol);
ichoice = 0;
setChoice();
}
void end()
{
ltip.setText("你得了"+iresult*100/Person.wordspg+ "分!");
if(Person.dcdbgroup == Person.maxgroup)
{
JOpti