S
聚色屋:点亮生活色彩,共绘斑斓梦想
首页
速度
优化工具
☰
首页
速度
收录
工具
首页
/
速度优化
/
揭秘“wwwwwxxxxx”:一次穿越时空的奇幻之旅
网站优化
九一制片厂:从梦想到现实的电影之旅
海外版8x8x8x8x8x8x8x8x8
2026-06-12 20:36:48
阅读时长:8分钟
562次阅读
核心内容摘要
7x7x7x7x:无限可能的数字游戏,解锁你的思维潜能
预期实现功能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模式相关记忆功能
抖漫app下载免费版最新版本-抖漫app下载免费版最新版本应用
相关标签
深夜的欲望指南:揭秘ACG里番、漫画与小说的极致诱惑之美
绝对领域:体育馆更衣室里的白袜与荷尔蒙博弈
520524路mooc
暗黑蘑菇17c爆料与暗黑爆料:一场信息风暴中的拨云见日_1
520886com视频解锁高清视界
《姿韵二》:薛婧用音乐雕刻的时光回廊
伊甸乐园2025入口直达官方版:开启数字时代的奇幻之旅
携手一起草www17com:点燃无限可能,共绘数字蓝图
《火影忍者》9.1免费观看重温经典,点燃青春的激情!_1
男生女生一起愁愁:解锁青春期那些说不出口的烦恼
原神芙宁娜被旅行者导管后状态异常
烟火人间,足下生辉:花火与腿法的绝妙交响
那些小心翼翼的爱:当“闭俗情侣”漫画描绘现实中的我们
寻觅初心,重拾那份“纯净如初”的美好
🔍
📑
文章目录
二、Pi0机器人模型效果实测:生成(50,14)维度数组对接ROS/Mujoco
三、ollama部署Phi-4-mini-reasoning完整流程:含模型验证、推理测试与日志分析
四、HG-ha/MTools实际案例:跨境电商卖家AI生成多语种商品描述+主图+视频
五、DeepSeek-R1-Distill-Qwen-7B实测:数学推理能力惊艳
🔥
热门优化文章
Flutter + OpenHarmony 对话框体系:AlertDialog、SimpleDialog 与 CupertinoAlertDialog 的跨平台兼容策略
2026-05-16 23:19:13
YOLO12实战:从图片上传到检测结果展示的全流程指南
2026-05-16 23:19:13
🛠️
实用工具推荐
ChatGPT O4 实战:如何通过智能调度提升大模型推理效率
XTOM蓝光三维扫描仪用于自由曲面微尺寸共性电路的增材制造
相关优化文章 推荐
移动端实时分割新选择:LiteSeg与MobileNetV2的完美搭配(附FPS测试对比)
2026-06-12 20:36:48 6分钟阅读
多平�解�缩工具
2026-06-12 20:36:48 7分钟阅读
Python实战:奥比中光Gemini Pro深度相机数据采集与可视化
2026-06-12 20:36:48 1分钟阅读
↑
百度百家号客服电话人工服务
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