Example usage for javax.swing JOptionPane ERROR_MESSAGE

List of usage examples for javax.swing JOptionPane ERROR_MESSAGE

Introduction

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

Prototype

int ERROR_MESSAGE

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

Click Source Link

Document

Used for error messages.

Usage

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);//w ww .  j a v  a 2  s .  c om
    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);
}

From source file:net.sourceforge.happybank.main.BankMain.java

/**
 * loads the customer account data/*from  w w  w . j av  a  2  s  .  c  om*/
 * 
 * @return success (positive) or failure (negative)
 */
protected int loadAccounts() {
    try {
        List<Customer> customers = bank.getCustomers();
        Iterator<Customer> custIter = customers.iterator();
        Customer cust = null;
        while (custIter.hasNext()) {
            cust = custIter.next();
            String cid = cust.getId();
            Customer customer = bank.getCustomer(cid);
            List<Account> accounts = bank.getAccounts(cid);
            Iterator<Account> accIter = accounts.iterator();
            Account acc = null;
            while (accIter.hasNext()) {
                acc = accIter.next();
                String aid = acc.getId();
                acc = bank.getAccount(aid);
                int row = accountEntries.getSelectedRow();
                if (acc == null)
                    break;
                accountModel.insert(new AccountData(aid, acc.getType(), acc.getBalance(), cust.getFirstName(),
                        cust.getLastName(), cid), row + 1);
            }
        }

        // refresh table
        accountEntries.tableChanged(new TableModelEvent(accountModel, 0, accountModel.getRowCount(),
                TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));
        accountEntries.repaint();
    } catch (Exception ex) {
        ex.printStackTrace();
        JOptionPane.showMessageDialog(null, "Error reading account data", "Read Error",
                JOptionPane.ERROR_MESSAGE);
        return -1;
    }
    return 0;
}

From source file:it.unibas.spicygui.controllo.provider.intermediatezone.MyEditProviderConst.java

private void getOffsetButton() {
    this.dialog.getOffsetButton().addActionListener(new ActionListener() {
        @Override/*from   w ww . j a  v a  2s.  c o  m*/
        public void actionPerformed(ActionEvent e) {
            if (!dialog.getTextSequenceName().getText().trim().equals("")) {
                if (dbDialog == null) {
                    dbDialog = new GetConstantFromDbDialog(WindowManager.getDefault().getMainWindow(),
                            caratteristiche, true);
                    dbDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                    dbDialog.setVisible(true);
                } else {
                    dbDialog.setVisible(true);
                }
            } else {
                JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
                        "Please insert a sequence name!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
}

From source file:hr.fer.zemris.vhdllab.platform.ui.wizard.testbench.NewTestbenchWizard.java

private String oldCode(String testbench, File targetFile) {
    java.awt.Component parent = null;

    CircuitInterface ci = metadataExtractionService.extractCircuitInterface(targetFile.getId());

    while (true) {
        InitTimingDialog initTimingDialog = new InitTimingDialog(parent, true, ci, testbench,
                targetFile.getProject().getName());
        initTimingDialog.startDialog();/*from ww  w  .  j  a v a 2 s . c  o  m*/
        if (initTimingDialog.getOption() != InitTimingDialog.OK_OPTION)
            return null;

        Testbench tb = null;

        try {
            tb = this.getInitialTestbench(initTimingDialog, targetFile.getName());
            this.addSignals(tb, ci);
            return tb.toXml();
        } catch (UniformTestbenchException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Error creating testbench",
                    JOptionPane.ERROR_MESSAGE);
            continue;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

From source file:com.devbury.mkremote.server.QuickLaunchServiceImpl.java

public ArrayList<LaunchItem> list(String dir) {
    Base64 base64 = new Base64();
    JFileChooser chooser = new JFileChooser();
    File new_dir = newFileDir(dir);
    logger.debug("Looking for files in {}", new_dir.getAbsolutePath());
    ArrayList<LaunchItem> items = new ArrayList<LaunchItem>();
    if (isSupported()) {
        if (new_dir.isDirectory()) {
            FilenameFilter filter = new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return !name.startsWith(".");
                }/*  w w w . ja v a 2s  . c  o m*/
            };
            for (File f : new_dir.listFiles(filter)) {
                if (!f.isHidden()) {
                    LaunchItem item = new LaunchItem();
                    item.setName(f.getName());
                    item.setPath(dir);
                    if (f.isDirectory()) {
                        if (isMac() && f.getName().endsWith(".app")) {
                            item.setType(LaunchItem.FILE_TYPE);
                            item.setName(f.getName().substring(0, f.getName().length() - 4));
                        } else {
                            item.setType(LaunchItem.DIR_TYPE);
                        }
                    } else {
                        item.setType(LaunchItem.FILE_TYPE);
                    }
                    Icon icon = chooser.getIcon(f);
                    BufferedImage bi = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
                            BufferedImage.TYPE_INT_RGB);
                    icon.paintIcon(null, bi.createGraphics(), 0, 0);
                    ByteArrayOutputStream os = new ByteArrayOutputStream();
                    try {
                        ImageIO.write(bi, "png", os);
                        item.setIcon(base64.encodeToString(os.toByteArray()));
                    } catch (IOException e) {
                        logger.debug("could not write image {}", e);
                        item.setIcon(null);
                    }
                    logger.debug("Adding LaunchItem : {}", item);
                    items.add(item);
                } else {
                    logger.debug("Skipping hidden file {}", f.getName());
                }
            }
        }
    } else {
        new Thread() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(null,
                        "We are sorry but quick launch is not supported on your platform",
                        "Quick Launch Not Supported", JOptionPane.ERROR_MESSAGE);
            }
        }.start();
    }
    return items;
}

From source file:au.com.jwatmuff.eventmanager.util.GUIUtils.java

public static void displayErrors(Component parent, List<String> errors) {
    StringBuilder sb = new StringBuilder();

    for (String error : errors)
        sb.append(" - " + error + "\n");

    JOptionPane.showMessageDialog(parent, sb.toString(), "Invalid Input", JOptionPane.ERROR_MESSAGE);
}

From source file:mobac.program.EnvironmentSetup.java

public static void checkFileSetup() {
    checkDirectory(DirectoryManager.userSettingsDir, "user settings", true);
    checkDirectory(DirectoryManager.atlasProfilesDir, "atlas profile", true);
    checkDirectory(DirectoryManager.tileStoreDir, "tile store", true);
    checkDirectory(DirectoryManager.tempDir, "temporary atlas download", true);
    if (!Settings.FILE.exists()) {
        try {//  ww  w. jav a  2s  . c o m
            FIRST_START = true;
            Settings.save();
        } catch (Exception e) {
            log.error("Error while creating settings.xml: " + e.getMessage(), e);
            String[] options = { "Exit", "Show error report" };
            int a = JOptionPane.showOptionDialog(null,
                    "Could not create file settings.xml - program will exit.", "Error", 0,
                    JOptionPane.ERROR_MESSAGE, null, options, options[0]);
            if (a == 1)
                GUIExceptionHandler.showExceptionDialog(e);
            System.exit(1);
        }
    }
}

From source file:com.emr.utilities.SqliteAddProcess.java

protected void done() {
    Boolean success = null;//from   w ww .j  a v  a  2  s. c o m
    try {
        success = get();
    } catch (InterruptedException ex) {
        Logger.getLogger(EditMappingsForm.class.getName()).log(Level.SEVERE, null, ex);
        success = false;
    } catch (ExecutionException ex) {
        Logger.getLogger(EditMappingsForm.class.getName()).log(Level.SEVERE, null, ex);
        success = false;
    }
    if (success) {
        JOptionPane.showMessageDialog(null, "Successfully saved process", "Success",
                JOptionPane.INFORMATION_MESSAGE);
    } else {
        JOptionPane.showMessageDialog(null, "Could not save process. Error details: " + error_msg, "Failed",
                JOptionPane.ERROR_MESSAGE);
    }
    jp.setIndeterminate(false);
    lbl.setText("<html><b color='green'>Done!</b></html>");
}

From source file:de.rub.nds.burp.espresso.gui.UIOptions.java

/**
 * Creates new form UIOptions/*from  www .  ja v a  2 s .  c o m*/
 */
public UIOptions() {
    initComponents();
    hideAllUnsedComponents();

    String path = System.getProperty("user.home") + "/EsPReSSO";
    String decoded_path = null;
    try {
        if (path != null) {
            decoded_path = URLDecoder.decode(path, "UTF-8");
            if (decoded_path != null) {
                File file = new File(decoded_path);
                if (!file.exists()) {
                    file.mkdir();
                }
                path = decoded_path + "/config.json";
                file = new File(path);
                if (!file.exists()) {
                    // First start no config created
                    file.createNewFile();
                    configText1.setText(path);
                    saveConfig(path);
                } else {
                    // load previous config
                    configText1.setText(path);
                    loadConfig(path);
                }
            }
        }
    } catch (UnsupportedEncodingException ex) {
        JOptionPane.showMessageDialog(this, ex.toString(), "ERROR 2", JOptionPane.ERROR_MESSAGE);
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(this, ex.toString(), "ERROR 2", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:io.bibleget.BibleGetSelection.java

public void getQuoteFromSelection() {
    List<String> preferredVersions = new ArrayList<>();
    Object retVal = biblegetDB.getOption("PREFERREDVERSIONS");
    if (null == retVal) {
    } else {//www  . ja v  a 2  s  .c om
        String[] favoriteVersions = StringUtils.split((String) retVal, ',');
        preferredVersions = Arrays.asList(favoriteVersions);
    }

    if (preferredVersions.isEmpty()) {
        preferredVersions.add("NVBSE");
    }

    String versions = StringUtils.join(preferredVersions.toArray(), ',');

    Object m_xCurSel;
    try {
        m_xCurSel = m_xTextDocument.getCurrentSelection();
        if (m_xCurSel != null) {
            //there is a selection, we can do something with it
            XIndexAccess xIndex = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, m_xCurSel);
            Object Sel0;
            try {
                Sel0 = xIndex.getByIndex(0);
                XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, Sel0);
                String myInputContent = xTextRange.getString();
                myInputContent = StringUtils.deleteWhitespace(myInputContent);
                //System.out.println("You typed : "+myInputContent);
                if (myInputContent.isEmpty() == false) {

                    HTTPCaller myHTTPCaller = new HTTPCaller();
                    String myResponse;
                    try {
                        Boolean querycheck = myHTTPCaller.integrityCheck(myInputContent, preferredVersions);
                        if (querycheck) {
                            //JOptionPane.showMessageDialog(null, "All is proceeding nicely", "progress info", JOptionPane.INFORMATION_MESSAGE);
                            myResponse = myHTTPCaller.sendGet(myInputContent, versions);
                            if (myResponse != null) {
                                xTextRange.setString("");
                                BibleGetJSON myJSON = new BibleGetJSON(m_xController);
                                myJSON.JSONParse(myResponse);
                            } else {
                                JOptionPane.showMessageDialog(null, __(
                                        "There was a problem communicating with the BibleGet server. Please try again."),
                                        "ERROR >> SERVER CONNECTIVITY ISSUE", JOptionPane.ERROR_MESSAGE);
                            }
                        } else {
                            String[] errorMessages = myHTTPCaller.getErrorMessages();
                            String errorDialog = StringUtils.join(errorMessages, "\n\n");
                            JOptionPane.showMessageDialog(null, errorDialog, "ERROR >> MALFORMED QUERYSTRING",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                    } catch (HeadlessException | ClassNotFoundException | UnknownPropertyException
                            | PropertyVetoException | com.sun.star.lang.IllegalArgumentException
                            | WrappedTargetException ex) {
                        Logger.getLogger(BibleGetFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } else {
                    JOptionPane.showMessageDialog(null, __("You cannot send an empty query."),
                            "ERROR >> EMPTY SELECTION", JOptionPane.ERROR_MESSAGE);
                }

            } catch (IndexOutOfBoundsException | WrappedTargetException ex) {
                Logger.getLogger(BibleGetSelection.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    } catch (Exception ex) {
        Logger.getLogger(BibleGetSelection.class.getName()).log(Level.SEVERE, null, ex);
    }
}