import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.JTextField;
//二级界面
public class jbButton implements ActionListener {
JFrame frame = new JFrame("进入默写模式");//实例化一个frame对象
Container container = frame.getContentPane();//创造一个容器
JPanel jp1,jp2;
//创建label话框
JLabel jl,jl1,jl2,jl3,jl4,jl5,jl6,jl7,jl8,jl9;
//创建textfield文本框
JTextField jt,jt1,jt2,jt3,jt4,jt5,jt6,jt7,jt8,jt9;
JButton jb1;
static int ar[] = new int[5];//保存English中的随机数
static int br[] = new int[5];//保存Chinese中的随机数
int count = 100;//设置分值
public jbButton(){
//创建面板
jp1 = new JPanel();
jp2 = new JPanel();
ArrayList<String> list1 = new ArrayList<String>();
ArrayList<String> a=jbButton.English(list1);//调用English()中的参数
ArrayList<String> list2 = new ArrayList<String>();
ArrayList<String> b=jbButton.Chinese(list2);//调用Chinese()中的参数
jl = new JLabel(a.get(0));
jt = new JTextField(10);
jl1 = new JLabel(b.get(0));
jt1 = new JTextField(10);
jl2 = new JLabel(a.get(1));
jt2 = new JTextField(10);
jl3 = new JLabel(b.get(1));
jt3 = new JTextField(10);
jl4 = new JLabel(a.get(2));
jt4 = new JTextField(10);
jl5 = new JLabel(b.get(2));
jt5 = new JTextField(10);
jl6 = new JLabel(a.get(3));
jt6 = new JTextField(10);
jl7 = new JLabel(b.get(3));
jt7 = new JTextField(10);
jl8 = new JLabel(a.get(4));
jt8 = new JTextField(10);
jl9 = new JLabel(b.get(4));
jt9 = new JTextField(10);
jb1 = new JButton("提交");
}
@Override
public void actionPerformed(ActionEvent e) {
jp1.add(jl);
jp1.add(jt);
jp1.add(jl1);
jp1.add(jt1);
jp1.add(jl2);
jp1.add(jt2);
jp1.add(jl3);
jp1.add(jt3);
jp1.add(jl4);
jp1.add(jt4);
jp1.add(jl5);
jp1.add(jt5);
jp1.add(jl6);
jp1.add(jt6);
jp1.add(jl7);
jp1.add(jt7);
jp1.add(jl8);
jp1.add(jt8);
jp1.add(jl9);
jp1.add(jt9);
container.add(jp1);
//设置jp1为网格布局,格式为5行2列10行距50间距
jp1.setLayout(new GridLayout(5,4,10,50));
jp1.setBackground(Color.orange);
jp2.add(jb1);
container.add(jp2,BorderLayout.SOUTH);
jp2.setBackground(Color.green);
jb1.addActionListener(new jbButton1());
frame.setSize(600, 450);//设置窗口大小
frame.setLocationRelativeTo(null);//在屏幕中间显示(居中显示)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static ArrayList<String> English(ArrayList<String> list1){
String[] a ={ "risk","positive","detemine","attract","assignment","account","local","major","pressure","outside","impact",
"current","data","desire","consumer","disease","recently","source","specific","advantage","appeal","understanding",
"nature","result","compete","expert","blank","issue","range","efficient","expand","market","challenge","remain",
"responsible","graduate","charge","contact","aware","management","measure","imply","limited","promote","decline",
"performance","critical","factor","application","staff","consequence","despite","apartment","harm","academic",
"extra","negative","increasingly","detail","kid","community","enormous","argue","profit","recognize","attempt",
"failure","survey","resource","competition","opportunity","household","responsibility","security","complaint",
"require","immediately","aspect","ignore","original"};
list1 = new ArrayList<String>();
for(int i=0;i<5;i++){
int random = (int)(Math.random()*80);//设置随机数
ar[i] = random;
list1.add(a[random]);//将产生的5个随机数存入一个新数组中
System.out.println(ar[i]);
}
System.out.println(list1);
return list1;
}
public static ArrayList<String> Chinese(ArrayList<String> list2){
String[] b ={"危险","确实的","决定","吸引","任务","记述","本地的","主要的","压力","外部","影响","当前的","数据","渴望","消费者","疾病","最近","根源",
"特有的","优点","呼吁","谅解","大自然","成果","比赛","专家","空白的","问题","一系列","效率高的","扩大","市场","挑战","剩下","需负责任的","毕业生",
"索价","联系","知道的","管理","测量","暗示","有限的","促进","下降","演出","批评的","因素","申请","参谋","后果","不管","公寓","伤害","学术的",
"额外的","消极的","日益","细节","小孩","社会","巨大的","争论","利益","认出","尝试","失败","调查","资源","竞争","机会","家庭","责任","安全",
"抱怨","要求","立即","方面","忽视","独创的"};
for(int i=0;i<5;i++){
int random = (int)(Math.random()*80);//设置随机数
br[i] = random;
list2.add(b[random]);//将产生的5个随机数存入一个新数组中
System.out.println(br[i]);
}
System.out.println(list2);
return list2;
}
public void Compare()//用于让Label 与 TextField的值进行比较
{
ArrayList<String> list1 = new ArrayList<String>();
ArrayList<String> a=jbButton.English(list1);//调用English()中的参数
ArrayList<String> list2 = new ArrayList<String>();
ArrayList<String> b=jbButton.Chinese(list2);//调用Chinese()中的参数
/*if(!c.get(0).equals(b.get(ar[0])))
count-=10;*/
System.out.println(jt.getText());
}
public static void main(String[] args) {
/*ArrayList<String> list1 = new ArrayList<String>();
ArrayList<String> list2 = new ArrayList<String>();
English(list1);
Chinese(list2);*/
}