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

📄 dbpractice.java

📁 小键盘指法练习 我是初学者
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
import java.util.Random;
//import java.lang.*;
import javax.swing.*;
import javax.swing.text.*;
public class DBPractice
{
	JTextField timetext;
	JLabel tlabel,rlabel[],overlabel,practicelabel,timelabel,speedlabel,ratelabel,numlabel,endplabel,endslabel,endrlabel,endnlabel,infolabel;
	JPanel startpanel,practicepanel,endpanel,aboutpanel,helppanel;
	JTextField ftext[];
	TEvent timerevent=new TEvent();
	Timer timer=new Timer(1000,timerevent);
	int right=0,total=0,number=0,seconds=0,overtime=0,practicetime=0;
	//boolean judgement=true;
	Random random=new Random(100);
	//static Container container;
	public Container createContentPane()
	{
		JPanel contentpane=new JPanel();//new BorderLayout());
		contentpane.setLayout(null);
		contentpane.setOpaque(true);
		JLabel label;
		JButton button;
		//Timer timer;
		CEvent commandevent=new CEvent();
		
		IEvent input=new IEvent();
		DigitDocument document=new DigitDocument();
		
		
		
		tlabel=new JLabel("小 键 盘 数 字 录 入 指 法 练 习");
		contentpane.add(tlabel);//,BorderLayout.CENTER);
		tlabel.setBounds(150,30,280,25);
		//
		startpanel=new JPanel();
		startpanel.setLayout(null);
		label=new JLabel("================================================================");
		startpanel.add(label);
		label.setBounds(10,10,460,25);
		
		label=new JLabel("请输入练习时间:");
		startpanel.add(label);
		label.setBounds(80,60,120,25);
		
		timetext=new JTextField();
		timetext.setHorizontalAlignment(JTextField.RIGHT);
		timetext.setDocument(document);
		//timetext.setText();
		timetext.addActionListener(commandevent);
		startpanel.add(timetext);
		timetext.setBounds(180,120,100,25);
		
		label=new JLabel("秒");
		startpanel.add(label);
		label.setBounds(290,120,50,25);
		
		label=new JLabel("================================================================");
		startpanel.add(label);
		label.setBounds(10,210,400,25);
		
		button=new JButton("测试");
		button.addActionListener(commandevent);
		startpanel.add(button);
		button.setBounds(5,240,80,25);
		button=new JButton("练习");
		button.addActionListener(commandevent);
		startpanel.add(button);
		button.setBounds(100,240,80,25);
		button=new JButton("帮助");
		button.addActionListener(commandevent);
		startpanel.add(button);
		button.setBounds(195,240,80,25);
		button=new JButton("关于");
		button.addActionListener(commandevent);
		startpanel.add(button);
		button.setBounds(290,240,80,25);
		button=new JButton("退出");
		button.addActionListener(commandevent);
		startpanel.add(button);
		button.setBounds(385,240,80,25);
		
		contentpane.add(startpanel);
		startpanel.setBounds(10,80,485,280);
		//startpanel.setVisible(false);
		//
		practicepanel=new JPanel();
		practicepanel.setLayout(null);
		label=new JLabel("================================================================");
		practicepanel.add(label);
		label.setBounds(10,30,400,25);
		//
		overlabel=new JLabel("剩余时间:秒");
		practicepanel.add(overlabel);
		overlabel.setBounds(10,10,100,25);
		practicelabel=new JLabel("使用时间:秒");
		practicepanel.add(practicelabel);
		practicelabel.setBounds(180,10,100,25);
		timelabel=new JLabel("");
		practicepanel.add(timelabel);
		timelabel.setBounds(350,10,120,25);
		speedlabel=new JLabel("速度:字/分钟");
		practicepanel.add(speedlabel);
		speedlabel.setBounds(10,210,100,25);
		ratelabel=new JLabel("准确率:0%");
		practicepanel.add(ratelabel);
		ratelabel.setBounds(200,210,100,25);
		numlabel=new JLabel("击键次数:0");
		practicepanel.add(numlabel);
		numlabel.setBounds(380,210,100,25);
		
		//
		label=new JLabel("================================================================");
		practicepanel.add(label);
		label.setBounds(10,230,400,25);
		
		
		//while(judgement){judgement=false;
	
		rlabel=new JLabel[5];
		ftext=new JTextField[5];
		for(int i=0;i<5;i++)
		{
			//Float figure=random.nextFloat();figure*=100;
			//String str=String.valueOf(figure);str=str.substring(0,5);
			rlabel[i]=new JLabel();//str);
			practicepanel.add(rlabel[i]);
			rlabel[i].setBounds(30+85*i,70,50,25);
			ftext[i]=new JTextField();
			if(i>0){ftext[i].setEditable(false);}
			ftext[i].setHorizontalAlignment(JTextField.RIGHT);
			ftext[i].addActionListener(input);
			practicepanel.add(ftext[i]);
			ftext[i].setBounds(30+85*i,120,50,25);
		}
		//ftext[0].setEditable(false);
		//ftext[0].setFocusable(false);
		//ftext[1].setFocusable(true);
		//if(i>=5){		}
		//}
		/*for(int i=0;i<5;i++)
		{
			Float figure=random.nextFloat();
			figure*=100;
			String str=String.valueOf(figure);
			str=str.substring(0,5);
			rlabel[i].setText(str);
		}
		*/
		
		button=new JButton("测试");
		button.addActionListener(commandevent);
		practicepanel.add(button);
		button.setBounds(5,260,80,25);
		button=new JButton("结束");
		button.addActionListener(commandevent);
		practicepanel.add(button);
		button.setBounds(100,260,80,25);
		button=new JButton("帮助");
		button.addActionListener(commandevent);
		practicepanel.add(button);
		button.setBounds(195,260,80,25);
		button=new JButton("关于");
		button.addActionListener(commandevent);
		practicepanel.add(button);
		button.setBounds(290,260,80,25);
		button=new JButton("退出");
		button.addActionListener(commandevent);
		practicepanel.add(button);
		button.setBounds(385,260,80,25);
		
		contentpane.add(practicepanel);
		practicepanel.setBounds(10,60,485,290);
		practicepanel.setVisible(false);
		//
		endpanel=new JPanel();
		endpanel.setLayout(null);
		label=new JLabel("================================================================");
		endpanel.add(label);
		label.setBounds(10,10,400,25);
		
				
		endplabel=new JLabel("使用时间:秒");
		endpanel.add(endplabel);
		endplabel.setBounds(20,40,100,25);
		endslabel=new JLabel("速度:字/分钟");
		endpanel.add(endslabel);
		endslabel.setBounds(20,70,100,25);
		endrlabel=new JLabel("准确率:0%");
		endpanel.add(endrlabel);
		endrlabel.setBounds(20,100,100,25);
		endnlabel=new JLabel("击键次数:0");
		endpanel.add(endnlabel);
		endnlabel.setBounds(20,130,100,25);
		infolabel=new JLabel("");
		endpanel.add(infolabel);
		infolabel.setBounds(20,180,300,25);
		
		label=new JLabel("================================================================");
		endpanel.add(label);
		label.setBounds(10,210,400,25);
		
		button=new JButton("测试");
		button.addActionListener(commandevent);
		endpanel.add(button);
		button.setBounds(5,240,80,25);
		button=new JButton("继续");
		button.addActionListener(commandevent);
		endpanel.add(button);
		button.setBounds(100,240,80,25);
		button=new JButton("帮助");
		button.addActionListener(commandevent);
		endpanel.add(button);
		button.setBounds(195,240,80,25);
		button=new JButton("关于");
		button.addActionListener(commandevent);
		endpanel.add(button);
		button.setBounds(290,240,80,25);
		button=new JButton("退出");
		button.addActionListener(commandevent);
		endpanel.add(button);
		button.setBounds(385,240,80,25);
		
		contentpane.add(endpanel);
		endpanel.setBounds(10,80,485,280);
		endpanel.setVisible(false);
		//
		aboutpanel=new JPanel();
		aboutpanel.setLayout(null);
		
		label=new JLabel("================================================================");
		aboutpanel.add(label);
		label.setBounds(10,10,485,25);
		
		label=new JLabel("作者:wfg_sc");
		aboutpanel.add(label);
		label.setBounds(10,40,100,25);
		label=new JLabel("电子邮箱:scwfeng@163.com");
		aboutpanel.add(label);
		label.setBounds(10,80,300,25);
		label=new JLabel("电话:13154673838");
		aboutpanel.add(label);
		label.setBounds(10,120,200,25);
		label=new JLabel("QQ:31463694");
		aboutpanel.add(label);
		label.setBounds(10,160,200,25);
		label=new JLabel("非常感谢你的使用!");
		aboutpanel.add(label);
		label.setBounds(160,185,200,25);
		
		label=new JLabel("================================================================");
		aboutpanel.add(label);
		label.setBounds(10,210,485,25);
		
		button=new JButton("测试");
		button.addActionListener(commandevent);
		aboutpanel.add(button);
		button.setBounds(5,240,80,25);
		button=new JButton("继续");
		button.addActionListener(commandevent);
		aboutpanel.add(button);
		button.setBounds(100,240,80,25);
		button=new JButton("帮助");
		button.addActionListener(commandevent);
		aboutpanel.add(button);
		button.setBounds(195,240,80,25);
		button=new JButton("关于");
		button.addActionListener(commandevent);
		aboutpanel.add(button);
		button.setBounds(290,240,80,25);
		button=new JButton("退出");
		button.addActionListener(commandevent);
		aboutpanel.add(button);
		button.setBounds(385,240,80,25);
		
		contentpane.add(aboutpanel);
		aboutpanel.setBounds(10,80,485,280);
		aboutpanel.setVisible(false);
		//
		helppanel=new JPanel();
		helppanel.setLayout(null);
				
		JTextArea textarea=new JTextArea("一、打字姿势\n二、打字要领\n三、按键练习\n");
		textarea.setEditable(false);
		JScrollPane scrollpane=new JScrollPane(textarea);
		helppanel.add(scrollpane);
		scrollpane.setBounds(10,00,450,240);
		
				
		button=new JButton("测试");
		button.addActionListener(commandevent);
		helppanel.add(button);
		button.setBounds(5,250,80,25);
		button=new JButton("继续");
		button.addActionListener(commandevent);
		helppanel.add(button);
		button.setBounds(100,250,80,25);
		button=new JButton("帮助");
		button.addActionListener(commandevent);
		helppanel.add(button);
		button.setBounds(195,250,80,25);
		button=new JButton("关于");
		button.addActionListener(commandevent);
		helppanel.add(button);
		button.setBounds(290,250,80,25);
		button=new JButton("退出");
		button.addActionListener(commandevent);
		helppanel.add(button);
		button.setBounds(385,250,80,25);
		
		contentpane.add(helppanel);
		helppanel.setBounds(10,70,485,280);
		helppanel.setVisible(false);
				
		return contentpane;
	}
	//public JPanel create
	private class CEvent implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			if(e.getSource()==timetext)
			{

⌨️ 快捷键说明

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