public void actionPerformed(ActionEvent e) {
   String fileName = textFileName.getText();
   if ((fileName == null) || (fileName.length() <= 0)) {
     JOptionPane.showMessageDialog(
         null, "File name must be specified", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   File file = new File(fileName);
   if (!file.exists()) {
     JOptionPane.showMessageDialog(
         null, "Could not find file \"" + fileName + "\"", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   if (!file.isFile()) {
     JOptionPane.showMessageDialog(
         null, "Not a file: \"" + fileName + "\"", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   if (!file.canRead()) {
     JOptionPane.showMessageDialog(
         null,
         "Read permission denied for file \"" + fileName + "\"",
         "Error",
         JOptionPane.ERROR_MESSAGE);
     return;
   }
   String fileContents;
   try {
     byte[] rawFileContents = Files.readAllBytes(file.toPath());
     fileContents = new String(rawFileContents, StandardCharsets.UTF_8);
   } catch (IOException x) {
     JOptionPane.showMessageDialog(
         null,
         "Error reading from file \"" + fileName + "\"",
         "Error",
         JOptionPane.ERROR_MESSAGE);
     return;
   }
   textLogContents.setTextValue("");
   // Open the file and read the contents
   String logContents = swingSchema.getSchema().fileImport(fileName, fileContents);
   if (logContents == null) {
     logContents = "";
   }
   textLogContents.setTextValue(logContents);
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   CFBamSwingMainJFrame mainJFrame = null;
   {
     Container cont = getParent();
     while ((cont != null) && (!(cont instanceof CFBamSwingMainJFrame))) {
       cont = cont.getParent();
     }
     if (cont != null) {
       mainJFrame = (CFBamSwingMainJFrame) cont;
     }
   }
   char pw[] = textKeystorePassword.getPassword();
   String keystorePassword;
   if (pw != null) {
     keystorePassword = new String(pw);
   } else {
     keystorePassword = null;
   }
   CFBamClientConfigurationFile configFile = swingSchema.getClientConfigurationFile();
   String keystoreFileName = configFile.getKeyStore();
   boolean exitApp = false;
   boolean exitForm = false;
   boolean creatingKeystore = false;
   KeyStore keyStore = null;
   File keystoreFile = new File(keystoreFileName);
   if (!keystoreFile.exists()) {
     int userOption = JOptionPane.NO_OPTION;
     try {
       userOption =
           JOptionPane.showOptionDialog(
               null,
               "Would you like to create the keystore \""
                   + keystoreFileName
                   + "\"?\n"
                   + "Selecting No will exit the application so you can edit the client configuration file and restart.",
               "Create Keystore?",
               JOptionPane.YES_NO_OPTION,
               JOptionPane.QUESTION_MESSAGE,
               null,
               null,
               null);
     } catch (HeadlessException x) {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(), S_ProcName, "Caught HeadlessException -- " + x.getMessage(), x);
     }
     if (userOption == JOptionPane.YES_OPTION) {
       creatingKeystore = true;
       JInternalFrame nextForm = swingSchema.newCreateKeystoreJInternalFrame();
       getDesktopPane().add(nextForm);
       nextForm.setVisible(true);
       nextForm.show();
       Container cont = getParent();
       while ((cont != null) && (!(cont instanceof JInternalFrame))) {
         cont = cont.getParent();
       }
       if (cont != null) {
         JInternalFrame frame = (JInternalFrame) cont;
         try {
           frame.setClosed(true);
         } catch (Exception x) {
         }
       }
     } else {
       exitApp = true;
     }
   } else if (!keystoreFile.isFile()) {
     JOptionPane.showMessageDialog(
         null,
         "The referenced JCEKS keystore \"" + keystoreFileName + "\" is not a file.",
         "Error",
         JOptionPane.ERROR_MESSAGE,
         null);
     exitApp = true;
   } else if (!keystoreFile.canRead()) {
     JOptionPane.showMessageDialog(
         null,
         "Permission denied attempting to access JCEKS keystore \"" + keystoreFileName + "\".",
         "Error",
         JOptionPane.ERROR_MESSAGE,
         null);
     exitApp = true;
   }
   if ((!exitApp) && (!creatingKeystore)) {
     try {
       keyStore = KeyStore.getInstance("jceks");
       char[] caPassword = keystorePassword.toCharArray();
       FileInputStream input = new FileInputStream(keystoreFileName);
       keyStore.load(input, caPassword);
       input.close();
       swingSchema.setKeyStore(keyStore);
       exitForm = true;
     } catch (CertificateException x) {
       keyStore = null;
       JOptionPane.showMessageDialog(
           null,
           "Could not open keystore due to CertificateException -- " + x.getMessage(),
           "Error",
           JOptionPane.ERROR_MESSAGE,
           null);
       exitApp = true;
     } catch (IOException x) {
       keyStore = null;
       JOptionPane.showMessageDialog(
           null,
           "Could not open keystore due to IOException -- " + x.getMessage(),
           "Error",
           JOptionPane.ERROR_MESSAGE,
           null);
     } catch (KeyStoreException x) {
       keyStore = null;
       JOptionPane.showMessageDialog(
           null,
           "Could not open keystore due to KeyStoreException -- " + x.getMessage(),
           "Error",
           JOptionPane.ERROR_MESSAGE,
           null);
       exitApp = true;
     } catch (NoSuchAlgorithmException x) {
       keyStore = null;
       JOptionPane.showMessageDialog(
           null,
           "Could not open keystore due to NoSuchAlgorithmException -- " + x.getMessage(),
           "Error",
           JOptionPane.ERROR_MESSAGE,
           null);
       exitApp = true;
     }
   }
   if (exitApp) {
     swingSchema.setKeyStore(null);
     mainJFrame.exitApplication();
   } else if (exitForm) {
     JInternalFrame nextForm = swingSchema.newOpenDeviceKeyJInternalFrame();
     getDesktopPane().add(nextForm);
     nextForm.setVisible(true);
     nextForm.show();
     Container cont = getParent();
     while ((cont != null) && (!(cont instanceof JInternalFrame))) {
       cont = cont.getParent();
     }
     if (cont != null) {
       JInternalFrame frame = (JInternalFrame) cont;
       try {
         frame.setClosed(true);
       } catch (Exception x) {
       }
     }
   }
 }