模拟文字接龙,班里一天几个接龙真的烦死啦(仅供娱乐)
生活随笔
收集整理的這篇文章主要介紹了
模拟文字接龙,班里一天几个接龙真的烦死啦(仅供娱乐)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 布局設計
- 功能
- 效果圖
布局設計
JFormDesigner布局插件下載,30天限免,常用的自行破解
功能
展示主要代碼:
Get按鈕監聽函數(主功能代碼寫在這,可以獨立出去)
private void GetActionPerformed(ActionEvent e) {// 得到班級名單File file = new File(filePath);Reader input = null;try {input = new FileReader(file);} catch (FileNotFoundException fileNotFoundException) {fileNotFoundException.printStackTrace();}BufferedReader in = new BufferedReader(input);// 將名單中名字存進數組List<String> list = new ArrayList<String>();String name = new String();while (true){try {if (!((name = in.readLine()) != null)) break;} catch (IOException ioException) {ioException.printStackTrace();}list.add(name);}// 亂序處理,合并接龍信息頭輸出Collections.shuffle(list);Object[] res = list.toArray();outputFantan.setText("#接龍\n");outputFantan.setText(outputFantan.getText() + inputHeader.getText() + "\n");for (int i = 0; i < res.length; i++) {outputFantan.setText(outputFantan.getText() + "\n" + (i + 1) + ". " + res[i] + " " + type.getText());}}導入名單(JFileChooser)
private void menuItem1ActionPerformed(ActionEvent e) {JFileChooser jf = new JFileChooser();jf.showOpenDialog(this);//顯示打開的文件對話框File f = jf.getSelectedFile();//使用文件類獲取選擇器選擇的文件String s = f.getAbsolutePath();//返回路徑名//JOptionPane彈出對話框類,顯示絕對路徑名JOptionPane.showMessageDialog(this, s, "Successfully",JOptionPane.INFORMATION_MESSAGE);filePath = s;System.out.println(filePath);}技術交流、完整代碼請聯系微信:13168162412
效果圖
總結
以上是生活随笔為你收集整理的模拟文字接龙,班里一天几个接龙真的烦死啦(仅供娱乐)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html设置表格边框样式的方法
- 下一篇: html如何自定义标签