S
拾遗者:一段关于“扌臿扌喿”的时光漫游
首页
速度
优化工具
☰
首页
速度
收录
工具
首页
/
速度优化
/
聆听岁月的节拍,奏响人生的华章——“铿锵铿锵铿锵铿锵铿锵好多少”的深沉回响
网站优化
畅游NBA世界,尽在苏州ios晶体公司!
积极对积极对积极积极大全2025:点燃你的无限潜能,共赴人生巅峰!
2026-06-08 14:57:02
阅读时长:9分钟
562次阅读
核心内容摘要
拆解的乐趣:当男女并肩,30分钟的球鞋“解构”体验
预期实现功能V
0准备数据 找到 单词与翻译的对照数据 存入到文件中在程序中读取文件中的数据V
0:1:随机抽取单词去掉其中某个字母要求用户输入这个字母填空2给出中文翻译输入单词 实现拼写3抽取单词给出4个选项 要求选择V
0:错题记忆将之间出错的题在新的练习再重复出现刷题的规划15天一轮模式选择CET-4/6高考 中考 等
功能实现先从最简洁的界面开始大概界面预期效果如下可以看到这里我们需要创建JFrame窗口对象然后添加标签JLabel和按钮JButton组件为了方便区分我们把初始窗口写到showUI方法中由于后续点击按钮后要进行窗体刷新操作为了便于编写我们导入一个面板JPanel组件在面板上进行操作public void showUI() { //wl.setPanel(panel); wl.setWordsUI(this); JFrame jf new JFrame(背单词); jf.setTitle(背单词); jf.setSize(500,
; jf.setLocationRelativeTo(null);//窗体居中显示到屏幕正中间 jf.setDefaultCloseOperation(
; //jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); panel.setLayout(null);//没有布局所有的组件需要自己设置位置和大小 JLabel jl new JLabel(请选择题库); JButton jbu new JButton(CET-
; JButton jbu2 new JButton(CET-
; Font font new Font(微软雅黑, Font.BOLD,
;//设置字体 jl.setFont(font); jbu.setFont(font); jbu
setFont(font); panel.add(jl);//添加组件 panel.add(jbu); panel.add(jbu
; jl.setBounds(150, 100, 200,
;//调整位置 jbu.setBounds(150, 150, 200,
; jbu
setBounds(150, 200, 200,
; jbu.addActionListener(wl); jbu
addActionListener(wl); jf.add(panel);//添加面板 jf.setVisible(true);//可见 }初始界面设置完成后需要编写对应的响应操作我们可以创建一个WordListener监听类来编写对应的响应操作JButton组件对应的监听器为动作监听器ActionListener注意需要引用接口当我们点击按钮时触发以下判断注意这里的文件在项目同级文件夹下这里我们读取文件的方式为行读取先字符读取自动补全后将行读取操作放到字符读取第一个while循环内并将字符串根据#拆分成两部分分别存入engList数组和chnList数组内if(s.equals(CET-
){ //加载四级词库 File file new File(words/CET-
txt); //文件读取 //单个字节 FileReader fr null; try { fr new FileReader(file); //读取一行 BufferedReader br new BufferedReader(fr); while(true){ String line br.readLine(); if(linenull){ break; } //拆分字符串 String[] eng_chn line.split(#); engList.add(eng_chn[0]); chnList.add(eng_chn[1]); } } catch (FileNotFoundException ex) { throw new RuntimeException(ex); } catch (IOException ex) { throw new RuntimeException(ex); } //刷新界面 panel.removeAll();//移除 String wordgetWord(); UI.showUI2(word); Font font new Font(微软雅黑, Font.BOLD,
; /* JButton jbu new JButton(hello); jbu.setBounds(150,170,200,
; jbu.setFont(font); panel.add(jbu); */ //刷新 组件 panel.repaint(); panel.revalidate(); //出题 }getword函数作用为获取随机单词并挖空内容如下public String getWord(){ int sizeengList.size(); wordIndexran.nextInt(size); String wordengList.get(wordIndex); int word_lenword.length(); int indexran.nextInt(word_len); cword.charAt(index); String vwordword.substring(0,index)_word.substring(index1,word_len); return vword; }showUI2函数作用为显示新的标签挖空单词、输入框和按钮代码如下public void showUI2(String vword) { JLabel jlanew JLabel(请猜出单词缺失的字母); JLabel jl new JLabel(vword); JTextField jtf new JTextField(
; JButton jbu new JButton(提交); JButton jbu3 new JButton(下一个); Font font new Font(微软雅黑, Font.BOLD,
; jl.setFont(font); jtf.setFont(font); jbu.setFont(font); jbu
setFont(font); jla.setFont(font); jla.setBounds(150,0,300,
; jl.setBounds(150,50,300,
; jtf.setBounds(150,100,200,
; jbu.setBounds(150,200,200,
; jbu
setBounds(150,150,200,
; panel.add(jla); panel.add(jl); panel.add(jtf); panel.add(jbu); panel.add(jbu
; jbu
addActionListener(wl); jbu.addActionListener(wl); //将界面的组件对象的地址 传一份给监听器中声明的组件变量名 使得我们点击按钮时可以调用这些组件 设置文本 获取文本 wl.setWordsJla(jl); wl.setChJtf(jtf); }tips.由于showUI这里的标签、输入框和按钮需要重复使用所以需要传到监听类中方便后续使用、刷新和读取其他情况判断如下else if(s.equals(提交)){ String chchJtf.getText(); if (ch.length()
{ JOptionPane.showMessageDialog(panel,请输入答案); return; } char ncch.charAt(
; String wordengList.get(wordIndex); String chnchnList.get(wordIndex); if(cnc){ JOptionPane.showMessageDialog(panel,恭喜你回答正确 word chn); }else{ JOptionPane.showMessageDialog(panel,很抱歉回答错误 word chn); } }else if(s.equals(下一个)){ //下一题 String wordSgetWord(); wordJla.setText(wordS);//显示 chJtf.setText();//清空 }
完整代码添加了两种模式package HolidayMainPackage.day0125; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.*; import java.util.ArrayList; import java.util.Random; //退出 保存功能每过五秒自动保存一次 //优化 public class WordsListener implements ActionListener { //绝对路径 //相对路径 ArrayListString engList new ArrayList(); ArrayListString chnList new ArrayList(); ArrayListString transList new ArrayList();//我自己的单词历史记录 //编号 猜对的次数 单词 中文(写一个单词类把这些属性存入类似于c语言结构体和结构体数组) JPanel panel; mainV1 UI; JLabel wordJla; JTextField chJtf; Random rannew Random(); char c; int wordIndex; int pattern; public void setWordsUI(mainV1 ui){ this.UI ui; this.panel ui.panel; } public void setWordsJla(JLabel jl) { this.wordJla jl; } public void setChJtf(JTextField jtf) { this.chJtf jtf; } Override public void actionPerformed(ActionEvent e) { String s e.getActionCommand(); if(s.equals(CET-
){ //加载四级词库 File file new File(words/CET-
txt); //文件读取 //单个字节 FileReader fr null; try { fr new FileReader(file); //读取一行 BufferedReader br new BufferedReader(fr); while(true){ String line br.readLine(); if(linenull){ break; } //拆分字符串 String[] eng_chn line.split(#); engList.add(eng_chn[0]); chnList.add(eng_chn[1]); } } catch (FileNotFoundException ex) { throw new RuntimeException(ex); } catch (IOException ex) { throw new RuntimeException(ex); } //刷新界面 panel.removeAll();//移除 String wordgetWord(); UI.showUI2(word); Font font new Font(微软雅黑, Font.BOLD,
; /* JButton jbu new JButton(hello); jbu.setBounds(150,170,200,
; jbu.setFont(font); panel.add(jbu); */ //刷新 组件 panel.repaint(); panel.revalidate(); //出题 }else if(s.equals(提交)){ String chchJtf.getText(); if (ch.length()
{ JOptionPane.showMessageDialog(panel,请输入答案); return; } if(pattern
{ pattern1(ch); }else if(pattern
{ pattern2(ch); }else{ JOptionPane.showMessageDialog(panel,请选择题库); } }else if(s.equals(下一个)){ //下一题 pattern ran.nextInt(
; System.out.println(pattern); if(pattern
{ panel.removeAll();//移除 String wordgetWord(); UI.showUI2(word); }else if(pattern
{ panel.removeAll();//移除 String wordgetChinese(); UI.showUI2(word); System.out.println(pattern); }else{ JOptionPane.showMessageDialog(panel,请选择题库); } /*String wordSgetWord(); wordJla.setText(wordS);//显示 chJtf.setText();//清空 */ // 缺少这两行 panel.revalidate(); panel.repaint(); } } public String getWord(){ int sizeengList.size(); wordIndexran.nextInt(size); String wordengList.get(wordIndex); int word_lenword.length(); int indexran.nextInt(word_len); cword.charAt(index); return word.substring(0,index)_word.substring(index1,word_len); } public String getChinese(){ int sizechnList.size(); wordIndexran.nextInt(size); return chnList.get(wordIndex); } //字母填空 public void pattern1(String ch){ char ncch.charAt(
; String wordengList.get(wordIndex); String chnchnList.get(wordIndex); if(cnc){ JOptionPane.showMessageDialog(panel,恭喜你回答正确\n word chn); }else{ JOptionPane.showMessageDialog(panel,很抱歉回答错误\n word chn); } } public void pattern2(String ch){ String ncengList.get(wordIndex); String wordengList.get(wordIndex); String chnchnList.get(wordIndex); if(ch.equals(nc)){ JOptionPane.showMessageDialog(panel,恭喜你回答正确\n word chn); }else{ JOptionPane.showMessageDialog(panel,很抱歉回答错误\n word chn); } } }package HolidayMainPackage.day0125; import javax.swing.*; import java.awt.*; import java.util.Random; public class mainV1 { JPanel panel new JPanel(); WordsListener wl new WordsListener(); public void showUI() { //wl.setPanel(panel); wl.setWordsUI(this); JFrame jf new JFrame(背单词); jf.setTitle(背单词); jf.setSize(500,
; jf.setLocationRelativeTo(null);//窗体居中显示到屏幕正中间 jf.setDefaultCloseOperation(
; //jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); panel.setLayout(null);//没有布局所有的组件需要自己设置位置和大小 JLabel jl new JLabel(请选择题库); JButton jbu new JButton(CET-
; JButton jbu2 new JButton(CET-
; Font font new Font(微软雅黑, Font.BOLD,
; jl.setFont(font); jbu.setFont(font); jbu
setFont(font); panel.add(jl); panel.add(jbu); panel.add(jbu
; jl.setBounds(150, 100, 200,
; jbu.setBounds(150, 150, 200,
; jbu
setBounds(150, 200, 200,
; jbu.addActionListener(wl); jbu
addActionListener(wl); jf.add(panel); jf.setVisible(true); } public void showUI2(String vword) { JLabel jlanew JLabel(请猜出单词缺失的字母); JLabel jl new JLabel(vword); JTextField jtf new JTextField(
; JButton jbu new JButton(提交); JButton jbu3 new JButton(下一个); Font font new Font(微软雅黑, Font.BOLD,
; jl.setFont(font); jtf.setFont(font); jbu.setFont(font); jbu
setFont(font); jla.setFont(font); jla.setBounds(150,0,300,
; jl.setBounds(150,50,300,
; jtf.setBounds(150,100,200,
; jbu.setBounds(150,200,200,
; jbu
setBounds(150,150,200,
; panel.add(jla); panel.add(jl); panel.add(jtf); panel.add(jbu); panel.add(jbu
; jbu
addActionListener(wl); jbu.addActionListener(wl); //将界面的组件对象的地址 传一份给监听器中声明的组件变量名 使得我们点击按钮时可以调用这些组件 设置文本 获取文本 wl.setWordsJla(jl); wl.setChJtf(jtf); } public static void main(String[] args) { mainV1 main new mainV1(); main.showUI(); } }未完后续会更新V
0的选择模式和V
0模式相关记忆功能
免费吃瓜官网-免费吃瓜官网应用
相关标签
小白必看:Qwen3-ASR语音识别工具快速安装与使用技巧
中国激光设备自主研发实践:打标机赋能多行业应用
5步打造高效Android桌面体验:Windows Subsystem for Android零基础部署与性能调优指南
实时口罩检测-通用效果对比图集:不同分辨率/压缩率下的检测稳定性展示
零基础入门:手把手教你部署Qwen3-ASR语音识别模型
Qwen2.5-VL-7B视觉助手:5分钟本地部署教程,RTX 4090极速体验
StructBERT文本相似度开源镜像实战:低成本GPU算力适配,200MB内存高效运行
基于Qwen3-ASR-1.7B的智能语音备忘录开发实战
5分钟搞定:用Ollama玩转GLM-4.7-Flash模型服务
电子课本解析工具:破解教育资源获取难题的创新方案
微调后显存占用多少?Qwen2.5-7B实际监控数据
Emotion2Vec+ Large语音识别镜像使用避坑指南,少走弯路
前后端分离无人超市管理系统系统|SpringBoot+Vue+MyBatis+MySQL完整源码+部署教程
通过 C# 将 PPT 文档转换为 HTML 格式
🔍
📑
文章目录
二、国货之光:一品、二品、三品,绽放中国制造的卓越魅力
三、男人天堂:不止于享乐,更是人生进阶的秘密基地_2_2
四、老师的黑色双开真丝旗袍
五、17.c一起草:一场思想的碰撞,一次创新的启航
🔥
热门优化文章
Ciu7:解锁未来数字生活的新密码
2026-05-16 23:19:13
穿越时空的对话:西方艺术1444-47的深邃回响
2026-05-16 23:19:13
🛠️
实用工具推荐
从梯形图到智能家居:PLC在全自动洗衣机中的跨界应用启示
OpenClaw 龙虾免费小白完全安装笔记
相关优化文章 推荐
FreeModbus功能码详解:3分钟搞懂0x/1x/3x/4x寄存器的真实应用场景
2026-06-08 14:57:02 3分钟阅读
模拟IC实战—30天精通Sigma-delta(Σ-Δ) ADC 行为级建模与仿真
2026-06-08 14:57:02 6分钟阅读
Coze-Loop保姆级教程:粘贴代码即获专业级优化方案
2026-06-08 14:57:02 6分钟阅读
↑
百度百家号客服电话人工服务
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3