Example usage for javax.swing JOptionPane INFORMATION_MESSAGE

List of usage examples for javax.swing JOptionPane INFORMATION_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane INFORMATION_MESSAGE.

Prototype

int INFORMATION_MESSAGE

To view the source code for javax.swing JOptionPane INFORMATION_MESSAGE.

Click Source Link

Document

Used for information messages.

Usage

From source file:com.ln.gui.Main.java

public void gg() {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                f.setState(NORMAL);/*from  w w  w  .  j  av a2s . c  o  m*/
                f.setAlwaysOnTop(true);
                if (Configuration.popup == 1) {
                    JOptionPane.showMessageDialog(rootPane, ee, "Event Starting!",
                            JOptionPane.INFORMATION_MESSAGE);
                }
                f.setAlwaysOnTop(false);
            } catch (Exception e) {
            }
        }
    });
}

From source file:edu.harvard.i2b2.timeline.lifelines.PDOQueryClient.java

public static String sendQueryRequestSOAP(String XMLstr) {
    try {/*  w  w w.  ja  v  a2s  .  c  om*/
        HttpTransportProperties.Authenticator basicAuthentication = new HttpTransportProperties.Authenticator();

        basicAuthentication.setUsername(UserInfoBean.getInstance().getUserName());
        basicAuthentication.setPassword(UserInfoBean.getInstance().getUserPassword());

        OMElement payload = getQueryPayLoad(XMLstr);
        Options options = new Options();

        // options.setProperty(HTTPConstants.PROXY, proxyProperties);
        targetEPR = new EndpointReference(getPDOServiceName());
        options.setTo(targetEPR);

        options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, basicAuthentication);

        options.setTimeOutInMilliSeconds(900000);
        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

        ConfigurationContext configContext = ConfigurationContextFactory
                .createConfigurationContextFromFileSystem(null, null);

        // Blocking invocation
        ServiceClient sender = new ServiceClient(configContext, null);
        sender.setOptions(options);

        OMElement responseElement = sender.sendReceive(payload);
        // System.out.println("Client Side response " +
        // responseElement.toString());

        return responseElement.toString();

    } catch (AxisFault axisFault) {
        axisFault.printStackTrace();
        if (axisFault.getMessage().indexOf("No route to host") >= 0) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(null,
                            "Unable to make a connection to the remote server,\n this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        } else if (axisFault.getMessage().indexOf("Read timed out") >= 0) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(null,
                            "Unable to obtain a response from the remote server, this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
        return null;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:javaresturentdesktopclient.UserLogIn.java

private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed
    // TODO add your handling code here:
    String username = jTextField1.getText();
    // String username = jTextField1.getText();
    String password;//  w  ww . ja  v a2s  .  com
    password = jPasswordField1.getText();
    //List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
    //nameValuePairs.add(new BasicNameValuePair("registrationid", "123456789"));
    List<NameValuePair> paramList = new ArrayList<>();
    ServletRequest.setServletRequest(Constant.LOGIN_SERVLET);
    paramList.add(new BasicNameValuePair(Constant.KEY_COMMAND, Constant.KEY_LOGIN_METHOD));
    paramList.add(new BasicNameValuePair(Constant.KEY_USERNAME, username));
    paramList.add(new BasicNameValuePair(Constant.KEY_PASSWORD, password));

    String response = HttpClientUtil.postRequest(paramList);

    if (response.equalsIgnoreCase("success")) {
        JOptionPane.showMessageDialog(null, "Login Success", "Information", JOptionPane.INFORMATION_MESSAGE);
        Home_page go_for_hmpg = new Home_page(this);
        go_for_hmpg.setUserNameTextField(getUsername());
        go_for_hmpg.setVisible(true);
        go_for_hmpg.setResizable(false);
        this.hide();
        jPasswordField1.setText(null);
    } else
        JOptionPane.showMessageDialog(null, "Login Failed!" + "PLEASE GIVE THE CORRECT USER NAME AND PASSWORD",
                "Error Message", JOptionPane.ERROR_MESSAGE);

}

From source file:net.sf.keystore_explorer.gui.actions.ExportKeyPairCertificateChainAction.java

/**
 * Do action.//from  www .  ja v  a2 s.  c  om
 */
@Override
protected void doAction() {
    File exportFile = null;

    try {
        String alias = kseFrame.getSelectedEntryAlias();

        DExportCertificates dExportCertificates = new DExportCertificates(frame, alias, true);
        dExportCertificates.setLocationRelativeTo(frame);
        dExportCertificates.setVisible(true);

        if (!dExportCertificates.exportSelected()) {
            return;
        }

        exportFile = dExportCertificates.getExportFile();
        boolean pemEncode = dExportCertificates.pemEncode();
        boolean exportChain = dExportCertificates.exportChain();

        byte[] encoded = null;

        if (exportChain) {
            X509Certificate[] certChain = getCertificateChain(alias);

            if (dExportCertificates.exportFormatPkcs7()) {
                if (pemEncode) {
                    encoded = X509CertUtil.getCertsEncodedPkcs7Pem(certChain).getBytes();
                } else {
                    encoded = X509CertUtil.getCertsEncodedPkcs7(certChain);
                }
            } else if (dExportCertificates.exportFormatPkiPath()) {
                encoded = X509CertUtil.getCertsEncodedPkiPath(certChain);
            } else if (dExportCertificates.exportFormatSpc()) {
                // SPC is just DER PKCS #7
                encoded = X509CertUtil.getCertsEncodedPkcs7(certChain);
            }
        } else {
            X509Certificate cert = getHeadCertificate(alias);

            if (dExportCertificates.exportFormatX509()) {
                if (pemEncode) {
                    encoded = X509CertUtil.getCertEncodedX509Pem(cert).getBytes();
                } else {
                    encoded = X509CertUtil.getCertEncodedX509(cert);
                }
            } else if (dExportCertificates.exportFormatPkcs7()) {
                if (pemEncode) {
                    encoded = X509CertUtil.getCertEncodedPkcs7Pem(cert).getBytes();
                } else {
                    encoded = X509CertUtil.getCertEncodedPkcs7(cert);
                }
            } else if (dExportCertificates.exportFormatPkiPath()) {
                encoded = X509CertUtil.getCertEncodedPkiPath(cert);
            } else if (dExportCertificates.exportFormatSpc()) {
                encoded = X509CertUtil.getCertEncodedPkcs7(cert); // SPC is just DER PKCS #7
            }
        }

        exportEncodedCertificates(encoded, exportFile);

        JOptionPane.showMessageDialog(frame,
                res.getString("ExportKeyPairCertificateChainAction.ExportCertificateChainSuccessful.message"),
                res.getString("ExportKeyPairCertificateChainAction.ExportCertificateChain.Title"),
                JOptionPane.INFORMATION_MESSAGE);
    } catch (FileNotFoundException ex) {
        String message = MessageFormat
                .format(res.getString("ExportKeyPairCertificateChainAction.NoWriteFile.message"), exportFile);

        JOptionPane.showMessageDialog(frame, message,
                res.getString("ExportKeyPairCertificateChainAction.ExportCertificateChain.Title"),
                JOptionPane.WARNING_MESSAGE);
    } catch (Exception ex) {
        DError.displayError(frame, ex);
    }
}

From source file:de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.KgmlEdMain.java

/**
 * Constructs a new instance of the editor.
 *//* w  w  w . j a  v  a  2  s  .  co m*/
public KgmlEdMain(final boolean showMainFrame, String applicationName, String[] args) {
    // URL config,
    final ThreadSafeOptions tso = new ThreadSafeOptions();
    SplashScreenInterface splashScreen = new DBEsplashScreen(applicationName, "", new Runnable() {
        public void run() {
            if (showMainFrame) {
                ClassLoader cl = this.getClass().getClassLoader();
                String path = this.getClass().getPackage().getName().replace('.', '/');
                ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png"));
                final MainFrame mainFrame = MainFrame.getInstance();
                mainFrame.setIconImage(icon.getImage());

                Thread t = new Thread(new Runnable() {
                    public void run() {
                        long waitTime = 0;
                        long start = System.currentTimeMillis();
                        do {
                            if (ErrorMsg.getAppLoadingStatus() == ApplicationStatus.ADDONS_LOADED)
                                break;
                            try {
                                Thread.sleep(50);
                            } catch (InterruptedException e) {
                            }
                            waitTime = System.currentTimeMillis() - start;
                        } while (waitTime < 2000);
                        SplashScreenInterface ss = (SplashScreenInterface) tso.getParam(0, null);
                        ss.setVisible(false);
                        mainFrame.setVisible(true);
                    }
                }, "wait for add-on initialization");
                t.start();
            }

        }
    });
    tso.setParam(0, splashScreen);

    ClassLoader cl = this.getClass().getClassLoader();
    String path = this.getClass().getPackage().getName().replace('.', '/');
    ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png"));
    ((DBEsplashScreen) splashScreen).setIconImage(icon.getImage());

    splashScreen.setVisible(true);
    GravistoMainHelper.createApplicationSettingsFolder(splashScreen);
    if (!(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted")).exists()
            && !(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected")).exists()) {

        ReleaseInfo.setIsFirstRun(true);

        splashScreen.setVisible(false);
        splashScreen.setText("Request KEGG License Status");
        JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + "While "
                + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " is available as a academic research tool at no cost to commercial and non-commercial users, for using<br>"
                + "KEGG related functions, it is necessary for all users to adhere to the KEGG license.<br>"
                + "For using " + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " you need also be aware of information about licenses and conditions for<br>"
                + "usage, listed at the program info dialog and the " + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " website (" + ReleaseInfo.getAppWebURL() + ").<br><br>"
                + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " does not distribute information from KEGG but contains functionality for the online-access to  information from KEGG wesite.<br><br>"
                + "<b>Before these functions are available to you, you should  carefully read the following license information<br>"
                + "and decide if it is legit for you to use the KEGG related program functions. If you choose not to use the KEGG functions<br>"
                + "all other features of this application are still available and fully working.",
                DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                JOptionPane.INFORMATION_MESSAGE);

        JOptionPane.showMessageDialog(null,
                "<html><h3>KEGG License Status Evaluation</h3>" + MenuItemInfoDialog.getKEGGlibText(),
                DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                JOptionPane.INFORMATION_MESSAGE);

        int result = JOptionPane.showConfirmDialog(null, "<html><h3>Enable KEGG functions?",
                DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (result == JOptionPane.YES_OPTION) {
            try {
                new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted").createNewFile();
            } catch (IOException e) {
                ErrorMsg.addErrorMessage(e);
            }
        }
        if (result == JOptionPane.NO_OPTION) {
            try {
                new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected").createNewFile();
            } catch (IOException e) {
                ErrorMsg.addErrorMessage(e);
            }
        }
        if (result == JOptionPane.CANCEL_OPTION) {
            JOptionPane.showMessageDialog(null, "Startup aborted.",
                    DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                    JOptionPane.INFORMATION_MESSAGE);
            System.exit(0);
        }
        splashScreen.setVisible(true);
    }

    GravistoMainHelper.initApplicationExt(args, splashScreen, cl, null, null);

}

From source file:misc.TablePrintDemo1.java

/**
 * Constructs an instance of the demo.//ww w  . j a  va2  s.  c  om
 */
public TablePrintDemo1() {
    super("Table Printing Demo 1");

    gradesLabel = new JLabel("Final Grades - CSC 101");
    gradesLabel.setFont(new Font("Dialog", Font.BOLD, 16));

    gradesTable = createTable(new GradesModel());
    gradesTable.setFillsViewportHeight(true);
    gradesTable.setRowHeight(24);

    /* Set a custom renderer on the "Passed" column */
    gradesTable.getColumn("Passed").setCellRenderer(createPassedColumnRenderer());

    scroll = new JScrollPane(gradesTable);

    String tooltipText;

    tooltipText = "Include a page header";
    headerBox = new JCheckBox("Header:", true);
    headerBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            headerField.setEnabled(headerBox.isSelected());
        }
    });
    headerBox.setToolTipText(tooltipText);
    tooltipText = "Page Header (Use {0} to include page number)";
    headerField = new JTextField("Final Grades - CSC 101");
    headerField.setToolTipText(tooltipText);

    tooltipText = "Include a page footer";
    footerBox = new JCheckBox("Footer:", true);
    footerBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            footerField.setEnabled(footerBox.isSelected());
        }
    });
    footerBox.setToolTipText(tooltipText);
    tooltipText = "Page Footer (Use {0} to Include Page Number)";
    footerField = new JTextField("Page {0}");
    footerField.setToolTipText(tooltipText);

    tooltipText = "Show the Print Dialog Before Printing";
    showPrintDialogBox = new JCheckBox("Show print dialog", true);
    showPrintDialogBox.setToolTipText(tooltipText);
    showPrintDialogBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (!showPrintDialogBox.isSelected()) {
                JOptionPane.showMessageDialog(TablePrintDemo1.this,
                        "If the Print Dialog is not shown," + " the default printer is used.",
                        "Printing Message", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });

    tooltipText = "Keep the GUI Responsive and Show a Status Dialog During Printing";
    interactiveBox = new JCheckBox("Interactive (Show status dialog)", true);
    interactiveBox.setToolTipText(tooltipText);
    interactiveBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (!interactiveBox.isSelected()) {
                JOptionPane.showMessageDialog(TablePrintDemo1.this,
                        "If non-interactive, the GUI is fully blocked" + " during printing.",
                        "Printing Message", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });

    tooltipText = "Shrink the Table to Fit the Entire Width on a Page";
    fitWidthBox = new JCheckBox("Fit width to printed page", true);
    fitWidthBox.setToolTipText(tooltipText);

    tooltipText = "Print the Table";
    printButton = new JButton("Print");
    printButton.setToolTipText(tooltipText);

    printButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            printGradesTable();
        }
    });

    contentPane = new JPanel();
    addComponentsToContentPane();
    setContentPane(contentPane);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(700, 600);
    setLocationRelativeTo(null);
}

From source file:org.esa.snap.timeseries.ui.graph.TimeSeriesGraphForm.java

private JPanel createButtonPanel(final String helpID) {
    showTimeSeriesForSelectedPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/SelectedPinSpectra24.gif"), true);
    showTimeSeriesForSelectedPinsButton.addActionListener(e -> {
        if (graphModel.isShowingAllPins()) {
            showTimeSeriesForAllPinsButton.setSelected(false);
            graphModel.setIsShowingAllPins(false);
        }//  w  w w.ja  va 2 s  .  c o  m
        graphModel.setIsShowingSelectedPins(showTimeSeriesForSelectedPinsButton.isSelected());
    });
    showTimeSeriesForSelectedPinsButton.setName("showTimeSeriesForSelectedPinsButton");
    showTimeSeriesForSelectedPinsButton.setToolTipText("Show time series for selected pin");

    //////////////////////////////////////////

    showTimeSeriesForAllPinsButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/PinSpectra24.gif"), true);
    showTimeSeriesForAllPinsButton.addActionListener(e -> {
        if (graphModel.isShowingSelectedPins()) {
            showTimeSeriesForSelectedPinsButton.setSelected(false);
            graphModel.setIsShowingSelectedPins(false);
        }
        graphModel.setIsShowingAllPins(showTimeSeriesForAllPinsButton.isSelected());
    });
    showTimeSeriesForAllPinsButton.setName("showTimeSeriesForAllPinsButton");
    showTimeSeriesForAllPinsButton.setToolTipText("Show time series for all pins");

    //////////////////////////////////////////

    showCursorTimeSeriesButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/CursorSpectrum24.gif"), true);
    showCursorTimeSeriesButton.addActionListener(
            e -> graphModel.setIsShowingCursorTimeSeries(showCursorTimeSeriesButton.isSelected()));
    showCursorTimeSeriesButton.setToolTipText("Show time series for cursor");
    showCursorTimeSeriesButton.setSelected(true);

    //////////////////////////////////////////

    exportTimeSeriesButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false);
    exportTimeSeriesButton.addActionListener(e -> {
        final ProductSceneView view = SnapApp.getDefault().getSelectedProductSceneView();

        JOptionPane.showMessageDialog(view, "Not available in the current version.", "Export data",
                JOptionPane.INFORMATION_MESSAGE);

        //@todo se remove message dialog and fix export that only the visible graph data will be exported
        //                if (view != null
        //                    && view.getProduct() != null
        //                    && view.getProduct().getProductType().equals(AbstractTimeSeries.TIME_SERIES_PRODUCT_TYPE)
        //                    && TimeSeriesMapper.getInstance().getTimeSeries(view.getProduct()) != null) {
        //
        //                    AbstractTimeSeries timeSeries = TimeSeriesMapper.getInstance().getTimeSeries(view.getProduct());
        //                    ExportTimeBasedText.export(mainPanel, timeSeries, helpID);
        //                }
    });
    exportTimeSeriesButton.setToolTipText("Export raster data time series of all pins");
    exportTimeSeriesButton.setName("exportTimeSeriesButton");
    final ProductSceneView sceneView = SnapApp.getDefault().getSelectedProductSceneView();
    if (sceneView != null) {
        exportTimeSeriesButton.setEnabled(sceneView.getProduct().getPinGroup().getNodeCount() > 0);
    } else {
        exportTimeSeriesButton.setEnabled(false);
    }

    AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help22.png"),
            false);
    helpButton.addActionListener(e -> new HelpCtx(helpID).display());
    helpButton.setToolTipText("Help");

    final TableLayout tableLayout = new TableLayout(1);
    tableLayout.setTablePadding(4, 4);
    tableLayout.setTableAnchor(TableLayout.Anchor.NORTHWEST);
    tableLayout.setTableFill(TableLayout.Fill.HORIZONTAL);
    tableLayout.setTableWeightX(1.0);
    tableLayout.setTableWeightY(0.0);
    JPanel buttonPanel = new JPanel(tableLayout);

    buttonPanel.add(showTimeSeriesForSelectedPinsButton);
    buttonPanel.add(showTimeSeriesForAllPinsButton);
    buttonPanel.add(showCursorTimeSeriesButton);
    buttonPanel.add(exportTimeSeriesButton);
    buttonPanel.add(tableLayout.createVerticalSpacer());
    buttonPanel.add(helpButton);
    return buttonPanel;
}

From source file:com.frostwire.gui.updates.UpdateMediator.java

public void showUpdateMessage() {
    if (latestMsg == null) {
        return;/*w w w . ja v  a  2s .c om*/
    }

    int result = JOptionPane.showConfirmDialog(null, latestMsg.getMessageInstallerReady(), I18n.tr("Update"),
            JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);

    if (result == JOptionPane.YES_OPTION) {
        startUpdate();
    }
}

From source file:dialog.DialogFunctionUser.java

private void actionEditUserNoController() {
    if (!isValidData()) {
        return;//  ww  w. java  2  s  .  c  o m
    }
    tfUsername.setEditable(false);
    String username = tfUsername.getText();
    String fullname = tfFullname.getText();
    String password = mUser.getPassword();
    if (tfPassword.getPassword().length == 0) {
        password = new String(tfPassword.getPassword());
        password = LibraryString.md5(password);
    }
    int role = cbRole.getSelectedIndex();
    User objUser;
    if (mAvatar != null) {
        objUser = new User(mUser.getIdUser(), username, password, fullname, role,
                new Date(System.currentTimeMillis()), mAvatar.getPath());
        if ((new ModelUser()).editItem(objUser)) {
            String fileName = FilenameUtils.getBaseName(mAvatar.getName()) + "-" + System.nanoTime() + "."
                    + FilenameUtils.getExtension(mAvatar.getName());
            Path source = Paths.get(mAvatar.toURI());
            Path destination = Paths.get("files/" + fileName);
            Path pathOldAvatar = Paths.get(mUser.getAvatar());
            try {
                Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
                Files.deleteIfExists(pathOldAvatar);
            } catch (IOException ex) {
                Logger.getLogger(DialogFunctionRoom.class.getName()).log(Level.SEVERE, null, ex);
            }
            ImageIcon icon = new ImageIcon(getClass().getResource("/images/ic_success.png"));
            JOptionPane.showMessageDialog(this.getParent(), "Sa thnh cng", "Success",
                    JOptionPane.INFORMATION_MESSAGE, icon);
        } else {
            JOptionPane.showMessageDialog(this.getParent(), "Sa tht bi", "Fail",
                    JOptionPane.ERROR_MESSAGE);
        }
    } else {
        objUser = new User(mUser.getIdUser(), username, password, fullname, role,
                new Date(System.currentTimeMillis()), mUser.getAvatar());
        if (mControllerUser.editItem(objUser, mRow)) {
            ImageIcon icon = new ImageIcon(getClass().getResource("/images/ic_success.png"));
            JOptionPane.showMessageDialog(this.getParent(), "Sa thnh cng", "Success",
                    JOptionPane.INFORMATION_MESSAGE, icon);
        } else {
            JOptionPane.showMessageDialog(this.getParent(), "Sa tht bi", "Fail",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
    mUser = objUser;
    this.dispose();
}

From source file:net.sf.keystore_explorer.gui.actions.ExportKeyPairPrivateKeyAction.java

private void exportAsPkcs8(PrivateKey privateKey, String alias) throws CryptoException, IOException {
    File exportFile = null;//from  w  ww .  j  ava 2  s . c o  m

    try {
        DExportPrivateKeyPkcs8 dExportPrivateKeyPkcs8 = new DExportPrivateKeyPkcs8(frame, alias,
                applicationSettings.getPasswordQualityConfig());
        dExportPrivateKeyPkcs8.setLocationRelativeTo(frame);
        dExportPrivateKeyPkcs8.setVisible(true);

        if (!dExportPrivateKeyPkcs8.exportSelected()) {
            return;
        }

        exportFile = dExportPrivateKeyPkcs8.getExportFile();
        boolean pemEncode = dExportPrivateKeyPkcs8.pemEncode();
        boolean encrypt = dExportPrivateKeyPkcs8.encrypt();

        Pkcs8PbeType pbeAlgorithm = null;
        Password exportPassword = null;

        if (encrypt) {
            pbeAlgorithm = dExportPrivateKeyPkcs8.getPbeAlgorithm();
            exportPassword = dExportPrivateKeyPkcs8.getExportPassword();
        }

        byte[] encoded = getPkcs8EncodedPrivateKey(privateKey, pemEncode, pbeAlgorithm, exportPassword);

        exportEncodedPrivateKey(encoded, exportFile);

        JOptionPane.showMessageDialog(frame,
                res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPkcs8Successful.message"),
                res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPkcs8.Title"),
                JOptionPane.INFORMATION_MESSAGE);
    } catch (FileNotFoundException ex) {
        String message = MessageFormat
                .format(res.getString("ExportKeyPairPrivateKeyAction.NoWriteFile.message"), exportFile);
        JOptionPane.showMessageDialog(frame, message,
                res.getString("ExportKeyPairPrivateKeyAction.ExportPrivateKeyPkcs8.Title"),
                JOptionPane.WARNING_MESSAGE);
    }
}