al_openitem.java

来自「简易词典」· Java 代码 · 共 30 行

JAVA
30
字号
import java.awt.event.*;
import java.io.*;
import java.util.*;

public class AL_openItem implements ActionListener
{
     private WordFinder mainFrame;
     private WordList dictionary;

     public AL_openItem(WordFinder mainFrame, WordList dictionary)
     {
          this.mainFrame = mainFrame;
          this.dictionary = dictionary;
     }

     public void actionPerformed(ActionEvent ae)
     {
          File theFile = mainFrame.openFile(); // 获取选择的文件
          if(theFile != null) { // 选择了文件
               try {
                    dictionary.setDictionary(theFile); // 用选定的文件设置词典
                    mainFrame.setTotal(dictionary.getDictionarySize()); // 显示词典大小
                    mainFrame.setList(dictionary.getDictionary()); // 显示词典中所有词
               } catch(IOException ioe) {
                    ioe.printStackTrace();
               }
          }
     }
}

⌨️ 快捷键说明

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