示例#1
0
    @Override
    public void actionPerformed(ActionEvent arg0) {

      // Get the file
      JFileChooser fc = new JFileChooser(Driver.prefs.get("save_location", ""));
      File f;
      FileNameExtensionFilter filter = new FileNameExtensionFilter("JPokemon Files", "jpkmn");

      fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
      fc.addChoosableFileFilter(filter);

      if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        f = fc.getSelectedFile();
        try {
          // Make sure the file is of type .jpkmn
          if (!f.getName()
              .substring(f.getName().lastIndexOf('.'), f.getName().length())
              .equalsIgnoreCase(".jpkmn")) {
            showFatalErrorMessage("not type .jpkmn");
          }

          // Store the default save location
          Driver.prefs.put("save_location", f.getAbsolutePath());
          Driver.prefs.flush();

          // Load game
          Scanner scan = new Scanner(f);
          player = Player.fromFile(scan);
          splash.dispose();
          new GameWindow(player);
        } catch (Exception e) {
          e.printStackTrace();
          showFatalErrorMessage("General Error");
        }
      } // End if
    }
示例#2
0
 @Override
 public void actionPerformed(ActionEvent arg0) {
   splash.dispose();
 }
示例#3
0
 @Override
 public void actionPerformed(ActionEvent arg0) {
   splash.dispose();
   player.createNew();
   new GameWindow(player);
 }