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.dragoniade.deviantart.favorites.FavoritesDownloader.java

private File getFile(Deviation da, String url, String filename, AtomicBoolean download,
        YesNoAllDialog matureMoveDialog, YesNoAllDialog overwriteDialog, YesNoAllDialog overwriteNewerDialog,
        YesNoAllDialog deleteEmptyDialog) {

    progress.setText("Downloading file '" + filename + "' from " + da.getArtist());

    String title = filename + " by " + da.getArtist();
    long timestamp = da.getTimestamp().getTime();
    File artPG = LocationHelper.getFile(destination, userId, da, filename);
    File artMature = LocationHelper.getFile(destinationMature, userId, da, filename);
    File art = null;//  ww  w .  j a  v a  2  s . c om

    if (da.isMature()) {
        if (artPG.exists()) {
            int resMove = matureMoveDialog.displayDialog(owner, title,
                    "This deviation labeled as mature already exists in the main download path.\n Do you want to move the current file to the mature path?");
            if (resMove == YesNoAllDialog.CANCEL) {
                return null;
            }
            if (resMove == YesNoAllDialog.YES) {
                File parent = artMature.getParentFile();
                if (!parent.mkdirs()) {
                    showMessageDialog(owner, "Unable to create '" + parent.getPath() + "'.", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return null;
                }

                if (artMature.exists()) {
                    int resOv = overwriteDialog.displayDialog(owner, "File already exists",
                            "The file '" + artMature.getPath() + "' already exists. Overwrite?");
                    if (resOv == YesNoAllDialog.YES) {
                        if (!artMature.delete()) {
                            showMessageDialog(owner, "Unable to delete '" + artMature.getPath() + "'.", "Error",
                                    JOptionPane.ERROR_MESSAGE);
                            return null;
                        }
                    } else {
                        return null;
                    }
                }
                if (!artPG.renameTo(artMature)) {
                    showMessageDialog(owner,
                            "Unable to move '" + artPG.getPath() + "' to '" + artMature.getPath() + "'.",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return null;
                }

                int resEmpty = deleteEmptyDialog.displayDialog(owner, "Delete", "Delete empty folders?");
                if (resEmpty == YesNoAllDialog.YES) {
                    deleteEmptyFolders(artPG);
                }

                if (resEmpty == YesNoAllDialog.CANCEL) {
                    return null;
                }

                download.set(false);
            }

            if (resMove == YesNoAllDialog.NO) {
                download.set(false);
            }
        }
        art = artMature;
    } else {
        art = artPG;
    }

    if (art.exists()) {
        if (timestamp > art.lastModified()) {
            int resOver = overwriteNewerDialog.displayDialog(owner, title,
                    "This deviation already exist but a newer version is available. Replace?");
            if (resOver == YesNoAllDialog.CANCEL) {
                return null;
            }

            if (resOver == YesNoAllDialog.NO) {
                download.set(false);
            } else {
                download.set(false);
            }
        } else {
            download.set(false);
        }
    }

    return art;
}

From source file:dialog.DialogFunctionUser.java

private void actionEditUserNoController() {
    if (!isValidData()) {
        return;// w w w . java 2s  .  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:com.googlecode.logVisualizer.LogVisualizer.java

private LogVisualizer() {
    try {//from w  w w  .j a v  a  2 s.com
        final String wantedLaf = Settings.getSettingString("LookAndFeel");
        LookAndFeelInfo usedLaf = null;
        for (final LookAndFeelInfo lafi : UIManager.getInstalledLookAndFeels())
            if (lafi.getName().equals(wantedLaf)) {
                usedLaf = lafi;
                break;
            }

        if (usedLaf != null)
            UIManager.setLookAndFeel(usedLaf.getClassName());
        else
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (final Exception e) {
        e.printStackTrace();
    }

    gui = new LogVisualizerGUI(new LogLoaderListener() {
        public void loadMafiaLog(final File file) {
            loadLog(file, new MafiaLogParser(file, Settings.getSettingBoolean("Include mafia log notes")));
        }

        public void loadPreparsedLog(final File file) {
            loadLog(file, new PreparsedLogParser(file));
        }

        public void loadXMLLog(final File file) {
            try {
                final LogDataHolder logData = XMLLogReader.parseXMLLog(file);
                addLogGUI(file, logData);
            } catch (final FileAccessException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(gui, "A problem occurred while reading the file.",
                        "Error occurred", JOptionPane.ERROR_MESSAGE);
            } catch (final XMLAccessException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(gui, "A problem occurred while parsing the XML.",
                        "Error occurred", JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    gui.setSize(800, 600);
    RefineryUtilities.centerFrameOnScreen(gui);
    gui.setVisible(true);

    if (Settings.getSettingBoolean("First program startup")) {
        final JLabel text = new JLabel(
                "<html>Note that <b>for the purpose of logging your own runs with KolMafia, it is best</b> to "
                        + "turn on all options but <i>Log adventures left instead of adventures used</i> under "
                        + "<i>General->Preferences->Session Logs</i> in KolMafia."
                        + "<br><br><br>This informational popup will only be displayed this once.</html>");
        text.setPreferredSize(new Dimension(550, 100));
        JOptionPane.showMessageDialog(gui, text, "KolMafia logging options", JOptionPane.INFORMATION_MESSAGE);

        Settings.setSettingBoolean("First program startup", false);
    }

    if (Settings.getSettingBoolean("Check Updates"))
        new Thread(new Runnable() {
            public void run() {
                if (ProjectUpdateViewer.isNewerVersionUploaded())
                    EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            UpdateDialog.showDialog(gui);
                        }
                    });
            }
        }).start();
}

From source file:edu.wpi.cs.wpisuitetng.janeway.gui.login.LoginController.java

/**
 * Method that is called by {@link LoginRequestObserver} if the login
 * request was successful./*w  w w .  ja va 2 s .  c  o m*/
 * @param response the response returned by the server
 */
public void loginSuccessful(ResponseModel response) {
    // Save the cookies
    List<String> cookieList = response.getHeaders().get("Set-Cookie");
    String cookieParts[];
    String cookieNameVal[];
    if (cookieList != null) { // if the server returned cookies
        for (String cookie : cookieList) { // for each returned cookie
            cookieParts = cookie.split(";"); // split the cookie
            if (cookieParts.length >= 1) { // if there is at least one part to the cookie
                cookieNameVal = cookieParts[0].split("="); // split the cookie into its name and value
                if (cookieNameVal.length == 2) { // if the split worked, add the cookie to the default NetworkConfiguration
                    NetworkConfiguration config = Network.getInstance().getDefaultNetworkConfiguration();
                    config.addCookie(cookieNameVal[0], cookieNameVal[1]);
                    Network.getInstance().setDefaultNetworkConfiguration(config);
                } else {
                    System.err.println("Received unparsable cookie: " + cookie);
                }
            } else {
                System.err.println("Received unparsable cookie: " + cookie);
            }
        }

        System.out.println(Network.getInstance().getDefaultNetworkConfiguration().getRequestHeaders()
                .get("cookie").get(0));

        // Select the project
        Request projectSelectRequest = Network.getInstance().makeRequest("login", HttpMethod.PUT);
        projectSelectRequest.addObserver(new ProjectSelectRequestObserver(this));
        projectSelectRequest.setBody(ConfigManager.getConfig().getProjectName());
        projectSelectRequest.send();
    } else {
        JOptionPane.showMessageDialog(view, "Unable to login: no cookies returned.", "Login Error",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:de.fhg.iais.asc.ui.parts.HarvesterPanel.java

private void init(final MyCortexModel myCortexModel) {
    // OAI-PMH URL
    this.oaipmhTextField = new JTextField(20);
    this.retrieveInformationButton = LocalizedUI.createButton("Contact_Repository", new ActionListener() {
        @Override//from w  ww .  j a  v  a  2s  .co  m
        public void actionPerformed(ActionEvent e) {
            MetadataFormatsAndSetNamesRetriever retriever = new MetadataFormatsAndSetNamesRetriever(
                    HarvesterPanel.this.oaipmhTextField.getText(), myCortexModel.getConfig().getASCState(),
                    myCortexModel.getConfig().get(AscConfiguration.OAIPMH_PROXYHOST, ""), //$NON-NLS-1$
                    Integer.valueOf(myCortexModel.getConfig().get(AscConfiguration.OAIPMH_PROXYPORT, 0)));

            String[] metadataformats = retriever.listMetadataFormats();
            HarvesterPanel.this.oaipmhMetadataComboBox.removeAllItems();
            for (String metadataformat : metadataformats) {
                HarvesterPanel.this.oaipmhMetadataComboBox.addItem(metadataformat);
            }

            HarvesterPanel.this.availableSets = retriever.listSets();

            if (metadataformats.length == 0 && HarvesterPanel.this.availableSets == null) {

                // get the frame the panel is embedded in
                Component currentComponent = HarvesterPanel.this;
                while (currentComponent.getParent() != null && !(currentComponent instanceof JFrame)) {
                    currentComponent = currentComponent.getParent();
                }
                final JFrame parentFrame = currentComponent instanceof JFrame ? (JFrame) currentComponent
                        : null;

                LocalizedOptionPane.showMessageDialog(parentFrame, "UnableToContactRepository",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }

        }
    });
    this.add("OAI-PMH_URL", this.oaipmhTextField, this.retrieveInformationButton);

    this.oaipmhMetadataComboBox = this.add("Metadata_format", new JComboBox());
    this.oaipmhMetadataComboBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Object item = HarvesterPanel.this.oaipmhMetadataComboBox.getSelectedItem();
            myCortexModel.setSelectedMetadataFolder(ObjectUtils.toString(item, null));
        }
    });
    this.oaipmhMetadataFormatLabel = this.getLastLabel();

    this.setsTextField = this.add("Sets", createSetsTextField());

    this.harvestingStrategyComboBox = this.add("Harvesting_Strategy", new JComboBox(HARVEST_STRATEGIES));
    this.harvestingStrategyComboBox.setSelectedIndex(0);

    this.fromDateTextField = this.add("From_date", new DatePickerJTextField());

    this.untilDateTextField = this.add("Until_date", new DatePickerJTextField());

    this.inboxfolder = myCortexModel.getConfig().get(INBOX,
            MyCortex.DEFAULT_REPOSITORY_LOCATION + "/asc/inbox"); //$NON-NLS-1$
    this.outboxfolder = myCortexModel.getConfig().get(OUTBOX,
            MyCortex.DEFAULT_REPOSITORY_LOCATION + "/asc/outbox"); //$NON-NLS-1$
}

From source file:fr.insalyon.creatis.vip.vipcoworkapplet.Cowork.java

/** Initializes the applet Main */
@Override/*from ww w . j a  v  a 2  s. co  m*/
public void init() {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(Cowork.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Cowork.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Cowork.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Cowork.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    }
    //</editor-fold>

    /* Create and display the applet */
    try {
        java.awt.EventQueue.invokeAndWait(new Runnable() {

            public void run() {
                try {
                    sessionId = getParameter("sessionId");
                    email = getParameter("email");
                    endpoint = getCodeBase().toString() + "/fr.insalyon.creatis.vip.portal.Main/coworkservice";

                    DesignFrame frame = new DesignFrame(true);
                    frame.setAppletParams(endpoint, email, sessionId);

                    String home = System.getProperty("user.home");
                    File config = new File(home + File.separator + ".cowork/config");
                    PropertiesConfiguration pc = new PropertiesConfiguration(config);

                    String password = (String) pc.getProperty("password"),
                            login = (String) pc.getProperty("login");
                    PasswordDialog p = new PasswordDialog(null, "Please login to the knowledge base");
                    while (password == null || login == null) {
                        if (p.showDialog()) {

                            login = p.getName();
                            password = p.getPass();
                        }
                        if (login != null && password != null) {
                            if (JOptionPane.showConfirmDialog(null, "Remember credentials (unencrypted)?",
                                    "Rememeber?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                                pc.setProperty("password", password);
                                pc.setProperty("login", login);
                                pc.save();
                            }
                        }

                    }

                    KnowledgeBase kb = new KnowledgeBase("jdbc:mysql://" + getCodeBase().getHost() + "/cowork",
                            login, password, "http://cowork.i3s.cnrs.fr/");
                    frame.setKB(kb);
                    frame.setVisible(true);
                } catch (ConfigurationException ex) {
                    ex.printStackTrace();

                    JOptionPane.showMessageDialog(null, ExceptionUtils.getStackTrace(ex), "Error",
                            JOptionPane.ERROR_MESSAGE);
                } catch (SQLException ex) {
                    ex.printStackTrace();
                    JOptionPane.showMessageDialog(null, ExceptionUtils.getStackTrace(ex), "Error",
                            JOptionPane.ERROR_MESSAGE);
                }

            }
        });
    } catch (Exception ex) {
        ex.printStackTrace();
        JOptionPane.showMessageDialog(null, ExceptionUtils.getStackTrace(ex), "Error",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:gui.EspecificacionesAnimal.java

public void cargarStick() {

    //System.out.println("Inicio Puerto");
    stick = new SR232(puertoStick, 3, parent, 1);
    //  stick.setEID(tf_Eid);
    //  stick.setTf_Peso(tf_PesoActual);

    if (!stick.puertoDisponible()) {

        JOptionPane.showMessageDialog(this,
                "No se pudo conectar al puerto serie " + puertoStick
                        + "\n las opciones de entrada estaran deshabilitadas ",
                gs_mensaje, JOptionPane.ERROR_MESSAGE);
        return;/*from ww  w .  j  a  va 2 s .co  m*/
    }
    stick.start();

    automatico = true;
}

From source file:com.yosanai.java.aws.console.AWSConsole.java

private void btnAccessActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnAccessActionPerformed
    if (null == config) {
        showConfig(false);// ww  w.j  a v a  2 s  .  c o  m
    }
    if (StringUtils.isBlank(config.getString(AWSConnectionProvider.AWS_KEY))) {
        showConfig(true);
    }
    try {
        awsConnectionProvider.updateEC2Config(true, config);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "" + e.getLocalizedMessage(),
                "Failed to initialize connection to AWS", JOptionPane.ERROR_MESSAGE);
    }
    if (null == console && null != awsConnectionProvider.getConnection()) {
        console = new MainAWSPanel();
        console.setParentFrame(this);
        console.setAwsConnectionProvider(awsConnectionProvider);
        getContentPane().add(console, BorderLayout.CENTER);
        invalidate();
        validate();
        console.init();
    }
}

From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java

private void jbtnReportActionPerformed(java.awt.event.ActionEvent evt) {
    if (!isValidHours()) {
        lblMessages.setText("Not a valid time!");
        return;/*w w w  .j  av a  2  s. c o  m*/
    }

    Integer id = null;
    Integer projectId = Integer.valueOf(CoreObject.getWorkingProjectId());
    Calendar cal = jDateChooser_IL.getCalendar();
    SimpleDateFormat df = new SimpleDateFormat(
            CoreObject.getGlobalProperties().getProperty(Constants.DATE_FORMAT_DATE));
    String date = df.format(cal.getTime());
    String hours = jtfHours.getText();
    String todoDescription = (String) jcbTodos.getSelectedItem();
    BasecampTodoItem todoItem = CoreObject.getTodoMap().get(todoDescription);
    Integer todoItemId = todoItem.getId();
    Integer personId = CoreObject.getCurrentProfile().getBasecampAccountId();
    String description = jtfDescription.getText();
    BasecampTimeEntry entry = new BasecampTimeEntry(id, projectId, personId, date, hours, description,
            todoItemId);
    String statusCode = BasecampBusiness.createTimeEntry(todoItemId.toString(), entry);
    if (statusCode.trim().equals("200") || statusCode.trim().equals("201")) {
        jtfHours.setText("0");
        jDateChooser_IL.setDate(new Date());
        jtfDescription.setText("");
        lblMessages.setText("Time entry has been saved!");
    } else {
        String message = "Connection with Basecamp service failed! Got status code " + statusCode;
        String title = "Error";
        int messageType = JOptionPane.ERROR_MESSAGE;
        JOptionPane.showMessageDialog(this, message, title, messageType);
    }
}

From source file:com.sec.ose.osi.util.Property.java

private Property() {

    boolean result = load();
    if (result == false) {
        JOptionPane.showMessageDialog(null,
                "\"" + PROPERTY_FILE + "\" is not existed or invalid.\nCannot run "
                        + Version.getApplicationNameNice() + "without this file.",
                "Exit", JOptionPane.ERROR_MESSAGE);
        log.debug("\"" + PROPERTY_FILE + "\" is not existed.\nCannot run OSI without this file.");
        System.exit(0);/*  w w  w  .j  a  va2 s  . com*/
    }

    initSpecialPropertyValues();

}