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:net.sf.keystore_explorer.gui.actions.ExportKeyPairPublicKeyAction.java

/**
 * Do action./*  w w  w.  jav a2s . c  o m*/
 */
@Override
protected void doAction() {
    File exportFile = null;

    try {
        String alias = kseFrame.getSelectedEntryAlias();

        DExportPublicKeyOpenSsl dExportPublicKey = new DExportPublicKeyOpenSsl(frame, alias);
        dExportPublicKey.setLocationRelativeTo(frame);
        dExportPublicKey.setVisible(true);

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

        exportFile = dExportPublicKey.getExportFile();
        boolean pemEncode = dExportPublicKey.pemEncode();

        PublicKey publicKey = getPublicKey(alias);

        byte[] encoded = null;

        if (pemEncode) {
            encoded = OpenSslPubUtil.getPem(publicKey).getBytes();
        } else {
            encoded = OpenSslPubUtil.get(publicKey);
        }

        exportEncodedPublicKey(encoded, exportFile);

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

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

From source file:gov.nih.nci.nbia.StandaloneDMV2.java

void checkCompatibility() {
    if (serverUrl.endsWith("DownloadServlet")) {
        this.serverUrl = serverUrl.concat("V2");
    }//w w  w  .j a  v a 2  s. c  o m

    if (!serverUrl.endsWith("DownloadServletV2")) {
        Object[] options = { "OK" };

        int n = JOptionPane.showOptionDialog(frame, serverVersionMsg, "Incompatible Server Notification",
                JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
        System.exit(n);
    }
}

From source file:eu.apenet.dpt.standalone.gui.XsdAdderActionListener.java

public void actionPerformed(ActionEvent e) {
    JFileChooser xsdChooser = new JFileChooser();
    xsdChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

    if (xsdChooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
        File file = xsdChooser.getSelectedFile();
        if (isXSD(file)) {
            XsdInfoQueryComponent xsdInfoQueryComponent = new XsdInfoQueryComponent(labels, file.getName());

            int result = JOptionPane.showConfirmDialog(parent, xsdInfoQueryComponent, "title",
                    JOptionPane.OK_CANCEL_OPTION);
            if (result == JOptionPane.OK_OPTION) {
                if (StringUtils.isEmpty(xsdInfoQueryComponent.getName())) {
                    errorMessage();//from   w w w.j a v  a  2s . c  o m
                } else {
                    if (saveXsd(file, xsdInfoQueryComponent.getName(), false,
                            xsdInfoQueryComponent.getXsdVersion(), xsdInfoQueryComponent.getFileType())) {
                        JRadioButton newButton = new JRadioButton(xsdInfoQueryComponent.getName());
                        newButton.addActionListener(new XsdSelectorListener(dataPreparationToolGUI));
                        dataPreparationToolGUI.getGroupXsd().add(newButton);
                        dataPreparationToolGUI.getAPEPanel().getApeTabbedPane().addToXsdPanel(newButton);
                        dataPreparationToolGUI.getAPEPanel().getApeTabbedPane()
                                .addToXsdPanel(Box.createRigidArea(new Dimension(0, 10)));
                        JOptionPane.showMessageDialog(parent, labels.getString("xsdSaved") + ".",
                                labels.getString("fileSaved"), JOptionPane.INFORMATION_MESSAGE, Utilities.icon);
                    } else {
                        errorMessage();
                    }
                }
            }
        } else {
            errorMessage();
        }
    }
}

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

/**
 * Do action.//from   ww w  .  ja va  2  s  .c o  m
 */
@Override
protected void doAction() {
    File exportFile = null;

    try {
        String alias = kseFrame.getSelectedEntryAlias();

        DExportPublicKeyOpenSsl dExportPublicKey = new DExportPublicKeyOpenSsl(frame, alias);
        dExportPublicKey.setLocationRelativeTo(frame);
        dExportPublicKey.setVisible(true);

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

        exportFile = dExportPublicKey.getExportFile();
        boolean pemEncode = dExportPublicKey.pemEncode();

        PublicKey publicKey = getPublicKey(alias);

        byte[] encoded = null;

        if (pemEncode) {
            encoded = OpenSslPubUtil.getPem(publicKey).getBytes();
        } else {
            encoded = OpenSslPubUtil.get(publicKey);
        }

        exportEncodedPublicKey(encoded, exportFile);

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

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

From source file:com.willwinder.universalgcodesender.ExperimentalWindow.java

/** Creates new form ExperimentalWindow */
public ExperimentalWindow() {
    this.backend = new GUIBackend();
    try {// ww  w  .j  ava  2 s.  c  om
        backend.applySettings(SettingsFactory.loadSettings());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    if (backend.getSettings().isShowNightlyWarning() && ExperimentalWindow.VERSION.contains("nightly")) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                String message = "This version of Universal Gcode Sender is a nightly build.\n"
                        + "It contains all of the latest features and improvements, \n"
                        + "but may also have bugs that still need to be fixed.\n" + "\n"
                        + "If you encounter any problems, please report them on github.";
                JOptionPane.showMessageDialog(new JFrame(), message, "", JOptionPane.INFORMATION_MESSAGE);
            }
        });
    }
    initComponents();
    initProgram();
    backend.addControllerListener(this);
    backend.addUGSEventListener(this);

    setSize(backend.getSettings().getMainWindowSettings().width,
            backend.getSettings().getMainWindowSettings().height);
    setLocation(backend.getSettings().getMainWindowSettings().xLocation,
            backend.getSettings().getMainWindowSettings().yLocation);

    commandPanel.loadSettings();
    connectionPanel.loadSettings();
    visualizerPanel.loadSettings();

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            commandPanel.saveSettings();
            connectionPanel.saveSettings();
            SettingsFactory.saveSettings(backend.getSettings());

            if (pendantUI != null) {
                pendantUI.stop();
            }
        }
    });
}

From source file:FileTree3.java

public FileTree3() {
    super("Directories Tree [Tool Tips]");
    setSize(400, 300);// w  w  w . j a  va 2  s. c om

    DefaultMutableTreeNode top = new DefaultMutableTreeNode(new IconData(ICON_COMPUTER, null, "Computer"));

    DefaultMutableTreeNode node;
    File[] roots = File.listRoots();
    for (int k = 0; k < roots.length; k++) {
        node = new DefaultMutableTreeNode(new IconData(ICON_DISK, null, new FileNode(roots[k])));
        top.add(node);
        node.add(new DefaultMutableTreeNode(new Boolean(true)));
    }

    m_model = new DefaultTreeModel(top);
    // NEW
    m_tree = new JTree(m_model) {
        public String getToolTipText(MouseEvent ev) {
            if (ev == null)
                return null;
            TreePath path = m_tree.getPathForLocation(ev.getX(), ev.getY());
            if (path != null) {
                FileNode fnode = getFileNode(getTreeNode(path));
                if (fnode == null)
                    return null;
                File f = fnode.getFile();
                return (f == null ? null : f.getPath());
            }
            return null;
        }
    };
    ToolTipManager.sharedInstance().registerComponent(m_tree);

    m_tree.putClientProperty("JTree.lineStyle", "Angled");

    TreeCellRenderer renderer = new IconCellRenderer();
    m_tree.setCellRenderer(renderer);

    m_tree.addTreeExpansionListener(new DirExpansionListener());

    m_tree.addTreeSelectionListener(new DirSelectionListener());

    m_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    m_tree.setShowsRootHandles(true);
    m_tree.setEditable(false);

    JScrollPane s = new JScrollPane();
    s.getViewport().add(m_tree);
    getContentPane().add(s, BorderLayout.CENTER);

    m_display = new JTextField();
    m_display.setEditable(false);
    getContentPane().add(m_display, BorderLayout.NORTH);

    m_popup = new JPopupMenu();
    m_action = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (m_clickedPath == null)
                return;
            if (m_tree.isExpanded(m_clickedPath))
                m_tree.collapsePath(m_clickedPath);
            else
                m_tree.expandPath(m_clickedPath);
        }
    };
    m_popup.add(m_action);
    m_popup.addSeparator();

    Action a1 = new AbstractAction("Delete") {
        public void actionPerformed(ActionEvent e) {
            m_tree.repaint();
            JOptionPane.showMessageDialog(FileTree3.this, "Delete option is not implemented", "Info",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    };
    m_popup.add(a1);

    Action a2 = new AbstractAction("Rename") {
        public void actionPerformed(ActionEvent e) {
            m_tree.repaint();
            JOptionPane.showMessageDialog(FileTree3.this, "Rename option is not implemented", "Info",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    };
    m_popup.add(a2);
    m_tree.add(m_popup);
    m_tree.addMouseListener(new PopupTrigger());

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    setVisible(true);
}

From source file:net.sf.jabref.openoffice.AutoDetectPaths.java

private boolean autoDetectPaths() {

    if (OS.WINDOWS) {
        List<File> progFiles = findProgramFilesDir();
        File sOffice = null;//from   ww w  . ja  v a  2  s .  c  o  m
        List<File> sofficeFiles = new ArrayList<>();
        for (File dir : progFiles) {
            if (fileSearchCancelled) {
                return false;
            }
            sOffice = findFileDir(dir, "soffice.exe");
            if (sOffice != null) {
                sofficeFiles.add(sOffice);
            }
        }
        if (sOffice == null) {
            JOptionPane.showMessageDialog(parent, Localization.lang(
                    "Unable to autodetect OpenOffice/LibreOffice installation. Please choose the installation directory manually."),
                    Localization.lang("Could not find OpenOffice/LibreOffice installation"),
                    JOptionPane.INFORMATION_MESSAGE);
            JFileChooser jfc = new JFileChooser(new File("C:\\"));
            jfc.setDialogType(JFileChooser.OPEN_DIALOG);
            jfc.setFileFilter(new javax.swing.filechooser.FileFilter() {

                @Override
                public boolean accept(File file) {
                    return file.isDirectory();
                }

                @Override
                public String getDescription() {
                    return Localization.lang("Directories");
                }
            });
            jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            jfc.showOpenDialog(parent);
            if (jfc.getSelectedFile() != null) {
                sOffice = jfc.getSelectedFile();
            }
        }
        if (sOffice == null) {
            return false;
        }

        if (sofficeFiles.size() > 1) {
            // More than one file found
            DefaultListModel<File> mod = new DefaultListModel<>();
            for (File tmpfile : sofficeFiles) {
                mod.addElement(tmpfile);
            }
            JList<File> fileList = new JList<>(mod);
            fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            fileList.setSelectedIndex(0);
            FormBuilder b = FormBuilder.create()
                    .layout(new FormLayout("left:pref", "pref, 2dlu, pref, 4dlu, pref"));
            b.add(Localization.lang("Found more than one OpenOffice/LibreOffice executable.")).xy(1, 1);
            b.add(Localization.lang("Please choose which one to connect to:")).xy(1, 3);
            b.add(fileList).xy(1, 5);
            int answer = JOptionPane.showConfirmDialog(null, b.getPanel(),
                    Localization.lang("Choose OpenOffice/LibreOffice executable"),
                    JOptionPane.OK_CANCEL_OPTION);
            if (answer == JOptionPane.CANCEL_OPTION) {
                return false;
            } else {
                sOffice = fileList.getSelectedValue();
            }

        } else {
            sOffice = sofficeFiles.get(0);
        }
        return setupPreferencesForOO(sOffice.getParentFile(), sOffice, "soffice.exe");
    } else if (OS.OS_X) {
        File rootDir = new File("/Applications");
        File[] files = rootDir.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isDirectory() && ("OpenOffice.org.app".equals(file.getName())
                        || "LibreOffice.app".equals(file.getName()))) {
                    rootDir = file;
                    break;
                }
            }
        }
        File sOffice = findFileDir(rootDir, SOFFICE_BIN);
        if (fileSearchCancelled) {
            return false;
        }
        if (sOffice == null) {
            return false;
        } else {
            return setupPreferencesForOO(rootDir, sOffice, SOFFICE_BIN);
        }
    } else {
        // Linux:
        String usrRoot = "/usr/lib";
        File inUsr = findFileDir(new File(usrRoot), SOFFICE);
        if (fileSearchCancelled) {
            return false;
        }
        if (inUsr == null) {
            inUsr = findFileDir(new File("/usr/lib64"), SOFFICE);
            if (inUsr != null) {
                usrRoot = "/usr/lib64";
            }
        }

        if (fileSearchCancelled) {
            return false;
        }
        File inOpt = findFileDir(new File("/opt"), SOFFICE);
        if (fileSearchCancelled) {
            return false;
        }
        if ((inUsr != null) && (inOpt == null)) {
            return setupPreferencesForOO(usrRoot, inUsr, SOFFICE_BIN);
        } else if (inOpt != null) {
            if (inUsr == null) {
                return setupPreferencesForOO("/opt", inOpt, SOFFICE_BIN);
            } else { // Found both
                JRadioButton optRB = new JRadioButton(inOpt.getPath(), true);
                JRadioButton usrRB = new JRadioButton(inUsr.getPath(), false);
                ButtonGroup bg = new ButtonGroup();
                bg.add(optRB);
                bg.add(usrRB);
                FormBuilder b = FormBuilder.create()
                        .layout(new FormLayout("left:pref", "pref, 2dlu, pref, 2dlu, pref "));
                b.add(Localization.lang(
                        "Found more than one OpenOffice/LibreOffice executable. Please choose which one to connect to:"))
                        .xy(1, 1);
                b.add(optRB).xy(1, 3);
                b.add(usrRB).xy(1, 5);
                int answer = JOptionPane.showConfirmDialog(null, b.getPanel(),
                        Localization.lang("Choose OpenOffice/LibreOffice executable"),
                        JOptionPane.OK_CANCEL_OPTION);
                if (answer == JOptionPane.CANCEL_OPTION) {
                    return false;
                }
                if (optRB.isSelected()) {
                    return setupPreferencesForOO("/opt", inOpt, SOFFICE_BIN);
                } else {
                    return setupPreferencesForOO(usrRoot, inUsr, SOFFICE_BIN);
                }
            }
        }
    }
    return false;
}

From source file:edu.harvard.i2b2.analysis.queryClient.CRCQueryClient.java

public static String sendPDQQueryRequestREST(String XMLstr) {
    try {/*from ww w  . j a  va2s  .  c o m*/
        MessageUtil.getInstance().setRequest("URL: " + getPDQServiceName() + "\n" + XMLstr);

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

        targetEPR = new EndpointReference(getPDQServiceName());
        options.setTo(targetEPR);

        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
        options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(600000));
        options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(600000));

        ServiceClient sender = new ServiceClient();
        sender.setOptions(options);

        OMElement responseElement = sender.sendReceive(payload);
        MessageUtil.getInstance()
                .setResponse("URL: " + getPDQServiceName() + "\n" + responseElement.toString());

        return responseElement.toString();
    } catch (AxisFault axisFault) {
        axisFault.printStackTrace();
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(null,
                        "Trouble with connection to 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:biz.wolschon.finance.jgnucash.actions.ToolPluginMenuAction.java

@Override
public void actionPerformed(final ActionEvent e) {
    try {//from   w  w  w  .  j a v a 2 s . c  om
        GnucashWritableFile wModel = myJGnucashEditor.getWritableModel();
        if (wModel == null) {
            JOptionPane.showMessageDialog(myJGnucashEditor, "No open file.",
                    "Please open a gnucash-file first!", JOptionPane.WARNING_MESSAGE);
            return;
        }

        // Activate plug-in that declares extension.
        myJGnucashEditor.getPluginManager().activatePlugin(ext.getDeclaringPluginDescriptor().getId());
        // Get plug-in class loader.
        ClassLoader classLoader = myJGnucashEditor.getPluginManager()
                .getPluginClassLoader(ext.getDeclaringPluginDescriptor());
        // Load Tool class.
        Class toolCls = classLoader.loadClass(ext.getParameter("class").valueAsString());
        // Create Tool instance.
        Object o = toolCls.newInstance();
        if (!(o instanceof ToolPlugin)) {
            LOGGER.error("Plugin '" + pluginName + "' does not implement ToolPlugin-interface.");
            JOptionPane.showMessageDialog(myJGnucashEditor, "Error",
                    "Plugin '" + pluginName + "' does not implement ToolPlugin-interface.",
                    JOptionPane.ERROR_MESSAGE);
            return;

        }
        ToolPlugin importer = (ToolPlugin) o;
        try {
            myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            GnucashWritableAccount selectedAccount = (GnucashWritableAccount) myJGnucashEditor
                    .getSelectedAccount();
            String message = importer.runTool(wModel, selectedAccount);
            if (message != null && message.length() > 0) {
                JOptionPane.showMessageDialog(myJGnucashEditor, "Tool OK",
                        "The tool-use was a success:\n" + message, JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (Exception e1) {
            LOGGER.error("Tool-use via Plugin '" + pluginName + "' failed.", e1);
            JOptionPane
                    .showMessageDialog(
                            myJGnucashEditor, "Error", "Tool-use via Plugin '" + pluginName + "' failed.\n"
                                    + "[" + e1.getClass().getName() + "]: " + e1.getMessage(),
                            JOptionPane.ERROR_MESSAGE);
        } finally {
            myJGnucashEditor.setCursor(Cursor.getDefaultCursor());
        }
    } catch (Exception e1) {
        LOGGER.error("Could not activate requested Tool-plugin '" + pluginName + "'.", e1);
        JOptionPane
                .showMessageDialog(
                        myJGnucashEditor, "Error", "Could not activate requested Tool-plugin '" + pluginName
                                + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(),
                        JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.orthancserver.OrthancConfigurationDialog.java

public OrthancConfigurationDialog() {
    final JPanel contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(20, 5, 5, 5));
    contentPanel.setLayout(new GridLayout2(0, 2, 20, 5));

    JLabel label = new JLabel("Name:");
    label.setHorizontalAlignment(JLabel.RIGHT);
    contentPanel.add(label);/*  ww  w  .  j  av  a2  s  .c  o m*/
    contentPanel.add(name_);

    label = new JLabel("URL:");
    label.setHorizontalAlignment(JLabel.RIGHT);
    contentPanel.add(label);
    contentPanel.add(url_);

    label = new JLabel("Username:");
    label.setHorizontalAlignment(JLabel.RIGHT);
    contentPanel.add(label);
    contentPanel.add(username_);

    label = new JLabel("Password:");
    label.setHorizontalAlignment(JLabel.RIGHT);
    contentPanel.add(label);
    contentPanel.add(password_);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(contentPanel, BorderLayout.NORTH);

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    getContentPane().add(buttonPane, BorderLayout.SOUTH);
    {
        {
            JButton test = new JButton("Test connection");
            test.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg) {
                    OrthancConnection orthanc = CreateConnection();
                    try {
                        JSONObject system = (JSONObject) orthanc.ReadJson("system");
                        JOptionPane.showMessageDialog(null,
                                "Successfully connected to this Orthanc server " + "(version: "
                                        + (String) system.get("Version") + ")!",
                                "Success", JOptionPane.INFORMATION_MESSAGE);
                    } catch (IOException e) {
                        JOptionPane.showMessageDialog(null, "Cannot connect to this Orthanc server!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                }
            });
            buttonPane.add(test);
        }
        {
            JButton okButton = new JButton("Add");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg) {
                    isSuccess_ = true;
                    setVisible(false);
                }
            });
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg) {
                    setVisible(false);
                }
            });
            buttonPane.add(cancelButton);
        }
    }

    setUndecorated(false);
    setSize(500, 500);
    setTitle("Add new server");
    setModal(true);
}