示例#1
1
  // --------------------------------actionConnect------------------------------
  private void actionConnect() {
    if (oParty == null) {
      JOptionPane.showMessageDialog(frame, "Make a party before trying to connect.");
      return;
    }

    String[] oResults = (String[]) DialogManager.show(DialogManager.CONNECT, frame);

    if (oResults[DialogManager.RETURN_IP].equals("cancel")) return;

    lblStatus3.setText("Connecting...");
    try {
      oConn.connect(
          oResults[DialogManager.RETURN_IP], Integer.parseInt(oResults[DialogManager.RETURN_PORT]));
    } catch (UnknownHostException e) {
      JOptionPane.showMessageDialog(
          frame,
          "The IP of the host cannot be determined.",
          "Unknown Host Exception",
          JOptionPane.ERROR_MESSAGE);
      frame.repaint();
      return;
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          frame, e.getMessage(), "Input/Output Exception", JOptionPane.ERROR_MESSAGE);
      frame.repaint();
      return;
    }
    echo("Connected to opponent!");

    tConn = new Thread(oConn, "conn");
    tConn.start();
    tMain = new Thread(this, "main");
    tMain.start();
  }
示例#2
0
  boolean doSaveNcml(String text, String filename) {
    if (debugNcmlWrite) {
      System.out.println("filename=" + filename);
      System.out.println("text=" + text);
    }

    File out = new File(filename);
    if (out.exists()) {
      int val =
          JOptionPane.showConfirmDialog(
              null,
              filename + " already exists. Do you want to overwrite?",
              "WARNING",
              JOptionPane.YES_NO_OPTION);
      if (val != JOptionPane.YES_OPTION) return false;
    }

    try {
      IO.writeToFile(text, out);
      JOptionPane.showMessageDialog(this, "File successfully written");
      return true;
    } catch (IOException ioe) {
      JOptionPane.showMessageDialog(this, "ERROR: " + ioe.getMessage());
      ioe.printStackTrace();
      return false;
    }
    // saveNcmlDialog.setVisible(false);
  }
示例#3
0
  public String generateDatabaseName() { // prompts user for database name
    String dbNameDefault = "MySQLDB";
    // String databaseName = "";

    do {
      databaseName =
          (String)
              JOptionPane.showInputDialog(
                  null,
                  "Enter the database name:",
                  "Database Name",
                  JOptionPane.PLAIN_MESSAGE,
                  null,
                  null,
                  dbNameDefault);
      if (databaseName == null) {
        DatabaseConvertGUI.setReadSuccess(false);
        return "";
      }
      if (databaseName.equals("")) {
        JOptionPane.showMessageDialog(null, "You must select a name for your database.");
      }
    } while (databaseName.equals(""));
    return databaseName;
  }
  public void buscarComputadora(JTable table) {
    JTextField marca = new JTextField();
    JTextField clave = new JTextField();
    Object[] mensaje = {
      "Marca:", marca,
      "Clave:", clave
    };

    int opcion =
        JOptionPane.showConfirmDialog(this, mensaje, "Buscar", JOptionPane.OK_CANCEL_OPTION);
    if (opcion == JOptionPane.OK_OPTION) {
      for (int i = 0; i < sistema.getEmpresa().getProductos().size(); i++) {
        try {
          if (marca
                  .getText()
                  .equalsIgnoreCase(sistema.getEmpresa().getProductos().get(i).getMarca())
              && Integer.parseInt(clave.getText())
                  == sistema.getEmpresa().getProductos().get(i).getClave()) {
            table.changeSelection(i, 0, false, false);
            JOptionPane.showMessageDialog(this, "Encontrado");
            return;
          }
        } catch (NumberFormatException ex) {
          JOptionPane.showMessageDialog(this, "Número inválido");
        }
      }
    }
    JOptionPane.showMessageDialog(this, "No se encontró el producto");
  }
示例#5
0
  public void JudgeWhoIsWinner() // 判断胜负
      {
    String winner = "";

    if (white == 0) {
      JOptionPane.showMessageDialog(null, "黑方胜!" + black + ":" + white);
      //			JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
      submit.setEnabled(false);
      winner = "黑";
    }
    if (black == 0) {
      JOptionPane.showMessageDialog(null, "白方胜!" + white + ":" + black);
      //			JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
      submit.setEnabled(false);
      winner = "白";
    }
    if (black + white == 64) {
      if (white > black) {
        JOptionPane.showMessageDialog(null, "白方胜!" + white + ":" + black);
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        submit.setEnabled(false);
        winner = "白";
      } else if (black > white) {
        JOptionPane.showMessageDialog(null, "黑方胜!" + black + ":" + white);
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        submit.setEnabled(false);
        winner = "白";
      } else if (black == white) {
        JOptionPane.showMessageDialog(null, "和局!");
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        winner = "";
      }
    }
  }
 public void actionPerformed(ActionEvent e) {
   String name = null;
   name =
       JOptionPane.showInputDialog(
           objUpdate.this,
           "Enter a name (eg. John Russell)",
           "Input Person",
           JOptionPane.QUESTION_MESSAGE);
   if (!(name == null)) {
     // prompt the user for a date
     String date = null;
     date =
         JOptionPane.showInputDialog(
             objUpdate.this,
             "Enter Date (eg. 06/17/1946)",
             "Input Person",
             JOptionPane.QUESTION_MESSAGE);
     if (!(date == null)) {
       // convert String to Date
       try {
         Date d = f.parse(date);
         p = new Person(name, d);
         persons.add(p);
         index = persons.lastIndexOf(p);
         displayRecord();
       } catch (ParseException ex) {
         JOptionPane.showMessageDialog(
             objUpdate.this, "Invalid date format!", "Input Error", JOptionPane.ERROR_MESSAGE);
       }
     }
   }
 }
示例#7
0
 private void saveBin() {
   fileChooser.resetChoosableFileFilters();
   fileChooser.addChoosableFileFilter(binFilter);
   fileChooser.setFileFilter(binFilter);
   if (fileChooser.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION) {
     try {
       File file = fileChooser.getSelectedFile();
       if (fileChooser.getFileFilter() == binFilter && !binFilter.accept(file)) {
         file = new File(file.getAbsolutePath() + binFilter.getExtensions()[0]);
       }
       if (file.exists()) {
         if (JOptionPane.showConfirmDialog(
                 frame, "File exists. Overwrite?", "Confirm", JOptionPane.YES_NO_OPTION)
             != JOptionPane.YES_OPTION) {
           return;
         }
       }
       FileOutputStream output = new FileOutputStream(file);
       for (char i : binary) {
         output.write(i & 0xff);
         output.write((i >> 8) & 0xff);
       }
       output.close();
     } catch (IOException e1) {
       JOptionPane.showMessageDialog(
           frame, "Unable to open file", "Error", JOptionPane.ERROR_MESSAGE);
       e1.printStackTrace();
     }
   }
 }
示例#8
0
 private void saveSrc() {
   fileChooser.resetChoosableFileFilters();
   fileChooser.addChoosableFileFilter(asmFilter);
   fileChooser.setFileFilter(asmFilter);
   if (fileChooser.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION) {
     try {
       File file = fileChooser.getSelectedFile();
       if (fileChooser.getFileFilter() == asmFilter && !asmFilter.accept(file)) {
         file = new File(file.getAbsolutePath() + asmFilter.getExtensions()[0]);
       }
       if (file.exists()) {
         if (JOptionPane.showConfirmDialog(
                 frame, "File exists. Overwrite?", "Confirm", JOptionPane.YES_NO_OPTION)
             != JOptionPane.YES_OPTION) {
           return;
         }
       }
       PrintStream output = new PrintStream(file);
       output.print(sourceTextarea.getText());
       output.close();
     } catch (IOException e1) {
       JOptionPane.showMessageDialog(
           frame, "Unable to open file", "Error", JOptionPane.ERROR_MESSAGE);
       e1.printStackTrace();
     }
   }
 }
示例#9
0
 @Override
 public void actionPerformed(ActionEvent e) {
   boolean isHaveNewDocument = false;
   for (int i = 0; i < td.getTabCount(); i++) { // 依序將檔案撈出
     TextDocument ta = (TextDocument) td.getComponentAt(i);
     if (ta.file == null) { // 判斷是否有新黨案,有的會將運用到預設儲存路徑
       isHaveNewDocument = true;
       break;
     }
   }
   // 有新黨案,但是卻沒設定預設路徑,將跳出警告
   if (isHaveNewDocument && default_auto_save_path == null) {
     JOptionPane.showMessageDialog(
         null,
         "請先設定自動儲存預設位置!\nEdit->Default AutoSave-Path",
         "Save error",
         JOptionPane.ERROR_MESSAGE);
     return;
   }
   if (td.getTabCount() > 0) {
     for (int i = 0; i < td.getTabCount(); i++) { // 依序儲存
       save(i);
     }
     System.out.println("Save pass!");
     JOptionPane.showMessageDialog(
         null, "可儲存的檔案已儲存檔案。\n新檔案儲存於預設位置" + default_auto_save_path + "目錄下.");
   } else {
     JOptionPane.showMessageDialog(null, "沒有檔案可以儲存!");
   }
 }
示例#10
0
  // Sucecion de Fibonacci
  static void suce() {
    int numero, a = 1, b = 0, c;
    StringBuffer sb = new StringBuffer();
    String s1 =
        JOptionPane.showInputDialog("Ingrese el numero hasta el que desea ver la sucesion : ");
    numero = Integer.parseInt(s1);
    while (a < numero) {
      a += b;
      sb.append(a + " , ");
      b += a;
      sb.append(b + " , ");
    }

    JOptionPane.showMessageDialog(null, "Fibonacci = " + sb);

    int numero2 =
        JOptionPane.showOptionDialog(
            null,
            "Seleccione",
            "Escoja",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            new Object[] {"Opcion 1", "Opcion 2", "Opcion 3"},
            "Opcion 3");
  }
示例#11
0
  // Function use to Save Records to File After Deleting the Record of User Choice.
  void deleteFile() {

    try {
      FileOutputStream fos = new FileOutputStream("Bank.dat");
      DataOutputStream dos = new DataOutputStream(fos);
      if (records != null) {
        for (int i = 0; i < total; i++) {
          for (int r = 0; r < 6; r++) {
            dos.writeUTF(records[i][r]);
            if (records[i][r] == null) break;
          }
        }
        JOptionPane.showMessageDialog(
            this,
            "Record has been Deleted Successfuly.",
            "BankSystem - Record Deleted",
            JOptionPane.PLAIN_MESSAGE);
        txtClear();
      } else {
      }
      dos.close();
      fos.close();
    } catch (IOException ioe) {
      JOptionPane.showMessageDialog(
          this,
          "There are Some Problem with File",
          "BankSystem - Problem",
          JOptionPane.PLAIN_MESSAGE);
    }
  }
  private static boolean validateOldConfigDir(
      @Nullable File installationHome,
      @Nullable File oldConfigDir,
      @NotNull ConfigImportSettings settings) {
    if (oldConfigDir == null) {
      if (installationHome != null) {
        JOptionPane.showMessageDialog(
            JOptionPane.getRootFrame(),
            ApplicationBundle.message(
                "error.invalid.installation.home",
                installationHome.getAbsolutePath(),
                settings.getProductName(ThreeState.YES)));
      }
      return false;
    }

    if (!oldConfigDir.exists()) {
      JOptionPane.showMessageDialog(
          JOptionPane.getRootFrame(),
          ApplicationBundle.message("error.no.settings.path", oldConfigDir.getAbsolutePath()),
          ApplicationBundle.message("title.settings.import.failed"),
          JOptionPane.WARNING_MESSAGE);
      return false;
    }
    return true;
  }
  public static int rollbackGUIConfigurationTransaction(String sConfigurationFileName) {

    String sConfigurationLockFile;
    File fFile;

    sConfigurationLockFile = new String(sConfigurationFileName + ".lck");

    try {
      fFile = new File(URLDecoder.decode(sConfigurationLockFile, "UTF-8"));
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          null, "URLDecoder.decode failed", "ConfigurationTransaction", JOptionPane.ERROR_MESSAGE);

      return 1;
    }

    if (fFile.delete() == false) {
      JOptionPane.showMessageDialog(
          null,
          "fFile.delete on " + sConfigurationLockFile + " failed",
          "ConfigurationTransaction",
          JOptionPane.ERROR_MESSAGE);

      return 3;
    }

    return 0;
  }
示例#14
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == salir) {
      JOptionPane.showMessageDialog(null, "Pantalla de Marlon");
    }

    if (e.getSource() == opc1) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }

    if (e.getSource() == opc2) {
      score = s + 10;
      JOptionPane.showMessageDialog(null, "Respuesta Correcta :0 ");
      Pregunta14 avance = new Pregunta14(score);
      dispose();
    }

    if (e.getSource() == opc3) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }

    if (e.getSource() == opc4) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }
  }
  @Override
  public void actionPerformed(ActionEvent arg0) {
    try {

      URL url = new URL(excelUrl);
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      int filesize = connection.getContentLength();
      float totalDataRead = 0;
      java.io.BufferedInputStream in = new java.io.BufferedInputStream(connection.getInputStream());
      java.io.FileOutputStream fos = new java.io.FileOutputStream(excelName);
      java.io.BufferedOutputStream bout = new BufferedOutputStream(fos, 14921);
      byte[] data = new byte[14921];
      int i = 0;
      JOptionPane jop2 = new JOptionPane("VitalHealth Test Automation Framework");
      JDialog k2 = jop2.createDialog("Please wait till file is downloaded");
      k2.setModal(false);
      k2.setVisible(true);

      while ((i = in.read(data, 0, 14921)) >= 0) {
        totalDataRead = totalDataRead + i;
        bout.write(data, 0, i);
        float Percent = (totalDataRead * 100) / filesize;
      }
      bout.close();
      in.close();
      // fos.close();
      k2.dispose();

    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "Sample Configuration file downloaded");
    }
  }
示例#16
0
 public void secureDelete() {
   int rw = tblItems.getSelectedRow();
   if (rw == -1) {
     JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   int idx = tblItems.convertRowIndexToModel(rw);
   if (JOptionPane.showConfirmDialog(
           frm,
           "Delete " + store.plainName(idx) + "?",
           "Confirm Delete",
           JOptionPane.YES_NO_OPTION)
       != JOptionPane.YES_OPTION) return;
   File del = store.delete(idx);
   store.fireTableDataChanged();
   if (del != null) {
     if (del.delete()) {
       // successful
       needsSave = true;
     } else {
       System.err.println("Delete " + del.getAbsolutePath() + " failed");
     }
   }
   updateStatus();
 }
示例#17
0
 public void totalExport() {
   File expf = new File("export");
   if (expf.exists()) rmrf(expf);
   expf.mkdirs();
   for (int sto = 0; sto < storeLocs.size(); sto++) {
     try {
       String sl =
           storeLocs.get(sto).getAbsolutePath().replaceAll("/", "-").replaceAll("\\\\", "-");
       File estore = new File(expf, sl);
       estore.mkdir();
       File log = new File(estore, LIBRARY_NAME);
       PrintWriter pw = new PrintWriter(log);
       for (int i = 0; i < store.getRowCount(); i++)
         if (store.curStore(i) == sto) {
           File enc = store.locate(i);
           File dec = sec.prepareMainFile(enc, estore, false);
           pw.println(dec.getName());
           pw.println(store.getValueAt(i, Storage.COL_DATE));
           pw.println(store.getValueAt(i, Storage.COL_TAGS));
           synchronized (jobs) {
             jobs.addLast(expJob(enc, dec));
           }
         }
       pw.close();
     } catch (IOException exc) {
       exc.printStackTrace();
       JOptionPane.showMessageDialog(frm, "Exporting Failed");
       return;
     }
   }
   JOptionPane.showMessageDialog(frm, "Exporting to:\n   " + expf.getAbsolutePath());
 }
 public void testYourselfProgress() {
   // Goes through the list from the last unmemorized word in the word list, testing a character on
   // characters,
   // pinyin and definition.
   if (choice == correct) {
     JOptionPane.showMessageDialog(null, "Correct!");
     if (current < wordIndex) { // Error check to see whether the quiz has reached the final word.
       // Goes through each word, testing the pinyin, character and the definition.
       if (progress % 3 == 0) {
         pinyinLoad();
         progress++;
       } else if (progress % 3 == 1) {
         characterLoad();
         progress++;
       } else if (progress % 3 == 2) {
         definitionLoad();
         progress++;
         // User has memorized the word
         words[current].setMemorized(true);
         current++; // Increments up to test the user on the new word.
       }
     } else {
       // If the test has gone on to the final word, closes the form and goes back to the main
       // form.
       saveWords();
       MainWindow start = new MainWindow();
       start.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       start.setVisible(true);
       this.dispose();
     }
   } else {
     JOptionPane.showMessageDialog(null, "Sorry, you got it wrong.");
   }
 }
示例#19
0
    public void actionPerformed(ActionEvent e) {
      if (readOnly) {
        return;
      }
      JFileChooser fc = getFileChooser();
      File currentDirectory = fc.getCurrentDirectory();

      if (!currentDirectory.exists()) {
        JOptionPane.showMessageDialog(
            fc,
            newFolderParentDoesntExistText,
            newFolderParentDoesntExistTitleText,
            JOptionPane.WARNING_MESSAGE);
        return;
      }

      File newFolder;
      try {
        newFolder = fc.getFileSystemView().createNewFolder(currentDirectory);
        if (fc.isMultiSelectionEnabled()) {
          fc.setSelectedFiles(new File[] {newFolder});
        } else {
          fc.setSelectedFile(newFolder);
        }
      } catch (IOException exc) {
        JOptionPane.showMessageDialog(
            fc,
            newFolderErrorText + newFolderErrorSeparator + exc,
            newFolderErrorText,
            JOptionPane.ERROR_MESSAGE);
        return;
      }

      fc.rescanCurrentDirectory();
    }
 public void actionPerformed(ActionEvent e) {
   Object jbX = e.getSource();
   if (jbX == jbReg) {
     String an = tfAutoNr.getText();
     if (rg.registruotiAuto(an)) rodytiAutoRinkinius();
     else
       JOptionPane.showMessageDialog(
           this,
           "Registracija neįvyko:\n" + "arba kartojasi auto numeris arba nėra neregistruotų");
   }
   if (jbX == jbRasti) {
     String pag = tfAutoNr.getText();
     Automobilis a = rg.regAuto.get(pag);
     pag += a == null ? " automobilis nerastas" : "=" + a;
     JOptionPane.showMessageDialog(this, pag);
   }
   if (jbX == jbSkaityti) {
     rg.neregAuto.clear();
     String ats = rg.skaitytiNeregAutos("ban.automoto");
     JOptionPane.showMessageDialog(this, ats);
     rodytiAutoRinkinius();
   }
   if (jbX == jbSaveObj) {
     saveObject(rg, "temp.obj");
   }
   if (jbX == jbLoadObj) {
     loadObject("temp.obj");
     rodytiAutoRinkinius();
   }
 }
 /**
  * Common event handling code - can handle desirable actions (such as buttons being clicked) and
  * undesirable actions (the window being closed) all in a common location.
  *
  * @param command a String representing the action that occurred.
  */
 private void processCommand(String command) {
   dialog.setVisible(false);
   if (CONNECT.equals(command)) {
     options.setValue(JOptionPane.OK_OPTION);
   } else {
     options.setValue(JOptionPane.CANCEL_OPTION);
   }
 }
 /**
  * Let the caller of this dialog know whether the user connected or cancelled.
  *
  * @return true if the user cancelled or closed the window.
  */
 public boolean userCanceled() {
   if (options.getValue() instanceof Integer) {
     int status = ((Integer) options.getValue()).intValue();
     return status != JOptionPane.OK_OPTION;
   } else {
     return false;
   }
 }
示例#23
0
 void writeNetCDF(String filename) {
   try {
     FileWriter2 writer = new FileWriter2(ds, filename, NetcdfFileWriter.Version.netcdf3);
     NetcdfFile result = writer.write();
     result.close();
     JOptionPane.showMessageDialog(this, "File successfully written");
   } catch (Exception ioe) {
     JOptionPane.showMessageDialog(this, "ERROR: " + ioe.getMessage());
     ioe.printStackTrace();
   }
 }
示例#24
0
 public void actionPerformed(ActionEvent e) {
   JFileChooser chooser = new JFileChooser();
   chooser.setDialogTitle("Load");
   int choice = 0;
   do {
     int result = chooser.showOpenDialog(null);
     if (result == JFileChooser.APPROVE_OPTION) {
       file = chooser.getSelectedFile();
       try {
         if (file != null) {
           fileName = file.getCanonicalPath();
           reader = new BufferedReader(new FileReader(fileName));
           String line;
           while ((line = reader.readLine()) != null) {
             myPatternList.add(line);
           }
           //							for(int i=0;i<myPatternList.size();i++) {
           //								responseArea.append(myPatternList.get(i)+"\n");
           //							}
         }
         choice = 2;
         reader.close();
       } catch (IOException c) {
         c.printStackTrace();
         Object[] options = new String[] {"Load New File", "Exit"};
         choice =
             JOptionPane.showOptionDialog(
                 null,
                 "Invalid FileChoosen." + "Would you like to load a new file " + "or exit?",
                 "Options",
                 JOptionPane.YES_NO_OPTION,
                 JOptionPane.ERROR_MESSAGE,
                 null,
                 options,
                 options[0]);
         if (choice == 1) System.exit(0);
       }
     } else if (result == JFileChooser.CANCEL_OPTION) {
       Object[] options = new String[] {"Load Different File", "Exit"};
       choice =
           JOptionPane.showOptionDialog(
               null,
               "Would you like to load a new file " + " or exit?",
               "Options",
               JOptionPane.YES_NO_OPTION,
               JOptionPane.ERROR_MESSAGE,
               null,
               options,
               options[0]);
       if (choice == 1) System.exit(0);
     }
   } while (choice == 0);
 }
示例#25
0
 void writeNcstreamHeader(String filename) {
   try {
     NcStreamWriter writer = new NcStreamWriter(ds, null);
     FileOutputStream fos = new FileOutputStream(filename);
     writer.sendHeader(fos);
     fos.close();
     JOptionPane.showMessageDialog(this, "File successfully written");
   } catch (Exception ioe) {
     JOptionPane.showMessageDialog(this, "ERROR: " + ioe.getMessage());
     ioe.printStackTrace();
   }
 }
示例#26
0
  /** Returns false if Exception is thrown. */
  private boolean setDirectory() {
    String pathStr = dirTF.getText().trim();
    if (pathStr.equals("")) pathStr = System.getProperty("user.dir");
    try {
      File dirPath = new File(pathStr);
      if (!dirPath.isDirectory()) {
        if (!dirPath.exists()) {
          if (recursiveCheckBox.isSelected())
            throw new NotDirectoryException(dirPath.getAbsolutePath());
          else throw new NotFileException(dirPath.getAbsolutePath());
        } else {
          convertSet.setFile(dirPath);
          convertSet.setDestinationPath(dirPath.getParentFile());
        }
      } else {
        // Set the descriptors
        setMatchingFileNames();

        FlexFilter flexFilter = new FlexFilter();
        flexFilter.addDescriptors(descriptors);
        flexFilter.setFilesOnly(!recursiveCheckBox.isSelected());

        convertSet.setSourcePath(dirPath, flexFilter);
        convertSet.setDestinationPath(dirPath);
      }
    } catch (NotDirectoryException e1) {
      final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption1");

      MessageFormat formatter;
      String info_msg;
      if (pathStr.equals("")) {
        info_msg = ResourceHandler.getMessage("notdirectory_dialog.info5");
      } else {
        formatter = new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info0"));
        info_msg = formatter.format(new Object[] {pathStr});
      }
      final String info = info_msg;

      JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);
      return false;
    } catch (NotFileException e2) {
      final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption0");

      MessageFormat formatter =
          new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info1"));
      final String info = formatter.format(new Object[] {pathStr});

      JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);
      return false;
    }

    return true; // no exception thrown
  }
示例#27
0
  public void save() {
    boolean isNoticed = false;
    if (!notice.isVisible()) {
      isNoticed = true;
      notice.setVisible(true);
      notice.setText("Saving...");
    }
    if (getOptions() != null) {
      DB database = null;
      try {
        database = factory.open(this.leveldbStore.getSelectedFile(), getOptions());
        DBIterator iterator = database.iterator();
        HashSet<byte[]> keys = new HashSet<>();

        for (iterator.seekToFirst(); iterator.hasNext(); iterator.next()) {
          keys.add(iterator.peekNext().getKey());
        }
        iterator.close();

        for (byte[] key : keys) {
          database.delete(key);
        }

        for (int i = 0; i < dataList.getModel().getSize(); ++i) {
          DBItem item = dataList.getModel().getElementAt(i);
          database.put(item.key, item.value);
        }
      } catch (Exception e) {
        JOptionPane.showMessageDialog(pane, "Unable to open database:\n" + e);
        e.printStackTrace();
      } finally {
        if (database != null) {
          try {
            database.close();
          } catch (IOException e) {
            JOptionPane.showMessageDialog(pane, "Unable to close database:\n" + e);
            e.printStackTrace();
          }
        }
        saveButton.setEnabled(false);
      }
    }
    if (isNoticed) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      notice.setVisible(false);
      notice.setText("");
    }
  }
 private void openFile() {
   JFileChooser chooser = new JFileChooser("c:\\Javafiles");
   int result = chooser.showOpenDialog(this);
   if (result == JFileChooser.CANCEL_OPTION)
     JOptionPane.showMessageDialog(this, "The dialog was cancelled.");
   else
     try {
       File file = chooser.getSelectedFile();
       JOptionPane.showMessageDialog(this, "File name: " + file.getName());
     } catch (Exception e) {
       JOptionPane.showMessageDialog(this, "Error opening input file " + e.toString());
     }
 }
示例#29
0
 public void secureAnalysis() {
   int rw = tblItems.getSelectedRow();
   if (rw != -1) {
     int idx = tblItems.convertRowIndexToModel(rw);
     String desc = store.describe(idx);
     if (JOptionPane.showConfirmDialog(frm, desc, "Details", JOptionPane.OK_CANCEL_OPTION)
         == JOptionPane.CANCEL_OPTION) return;
   }
   if (JOptionPane.showConfirmDialog(frm, store.tagDesc(), "Tags", JOptionPane.OK_CANCEL_OPTION)
       == JOptionPane.CANCEL_OPTION) return;
   if (JOptionPane.showConfirmDialog(
           frm, store.storeDesc(), "Storage", JOptionPane.OK_CANCEL_OPTION)
       == JOptionPane.CANCEL_OPTION) return;
 }
 @Override
 public void run() {
   try {
     receive();
   } catch (IOException ioException) {
     JOptionPane.showMessageDialog(null, "Problems with a server");
   } catch (InterruptedException interruptedException) {
     JOptionPane.showMessageDialog(null, "Interrupted exception thrown");
   } catch (ParserConfigurationException parserException) {
     parserException.printStackTrace();
   } catch (SAXException saxException) {
     saxException.printStackTrace();
   }
 }