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:be.ac.ua.comp.scarletnebula.gui.addserverwizard.AddServerWizard.java

public AddServerWizard(final JFrame parent, final GUI gui) {
    this.parent = parent;
    this.gui = gui;

    // Only show the choose provider page if more than one provider is
    // available.
    final AddServerWizardDataRecorder rec = new AddServerWizardDataRecorder();

    WizardPage firstPage = null;//from w ww .  j  a v  a  2s .c  om

    switch (CloudManager.get().getLinkedCloudProviderNames().size()) {
    case 0:
        JOptionPane.showMessageDialog(parent, "Please add a new CloudProvider before starting new servers.",
                "First add Provider", JOptionPane.ERROR_MESSAGE);
        final AddProviderWizard wiz = new AddProviderWizard();
        wiz.startModal(parent);
        return;
    case 1: // One provider -- user has to pick this one so skip the
            // page
        final CloudProvider prov = (CloudProvider) CloudManager.get().getLinkedCloudProviders().toArray()[0];
        rec.provider = prov;
        firstPage = new ChooseImagePage(prov);
        break;
    default:
        firstPage = new ChooseProviderPage();
        break;
    }
    final Wizard wiz = new Wizard(firstPage, rec, new SimpleWizardTemplate());
    wiz.addWizardListener(this);
    wiz.startModal("Start new server", 500, 400, parent);
}

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

/**
 * Constructor//from  w ww  . j a v  a  2s .  c om
 * @param servername {@link String} Server name
 * @param port {@link String} Server Mysql Port
 * @param dbName {@link String} Database name
 * @param username {@link String} Mysql Username
 * @param password {@link String} Password
 */
public DatabaseManager(String servername, String port, String dbName, String username, String password) {
    this.servername = servername;
    this.port = port;
    this.url = "jdbc:mysql://" + servername + ":" + port + "/";
    this.dbName = dbName;
    this.userName = username;
    this.password = password;
    this.driver = "com.mysql.jdbc.Driver";
    try {
        Class.forName(driver).newInstance();
        conn = DriverManager.getConnection(url + dbName, userName, password);
    } catch (SQLException ex) {
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
        JOptionPane.showMessageDialog(null, "SQLException: " + ex.getMessage(), "Exception!",
                JOptionPane.ERROR_MESSAGE);
    } catch (ClassNotFoundException cs) {
        System.out.println("Class not found: " + cs.getMessage());
        JOptionPane.showMessageDialog(null, "Class not found: " + cs.getMessage(), "Exception!",
                JOptionPane.ERROR_MESSAGE);
    } catch (InstantiationException | IllegalAccessException i) {
        System.out.println("Instantiation/Illegal State Error: " + i.getMessage());
        JOptionPane.showMessageDialog(null, "Instantiation/Illegal State Error: " + i.getMessage(),
                "Exception!", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.intuit.tank.tools.debugger.SaveTextAction.java

/**
 * //from  w w w. j a v a  2 s.  c  o m
 */
protected void showSaveDialog() {
    int response = saveAsChooser.showSaveDialog(parent);
    if (response == JFileChooser.APPROVE_OPTION) {
        File selectedFile = saveAsChooser.getSelectedFile();
        if (selectedFile.exists()) {
            int confirm = JOptionPane.showConfirmDialog(parent,
                    "Overwrite file " + selectedFile.getName() + "?");
            if (confirm != JOptionPane.YES_OPTION) {
                return;
            }
        }
        FileWriter fw = null;
        try {
            fw = new FileWriter(selectedFile);
            writer.writeText(fw);
        } catch (Exception e) {
            System.err.println("Error writing file: " + e.toString());
            e.printStackTrace();
            JOptionPane.showMessageDialog(parent, "Error writing file: " + e.toString(), "Error",
                    JOptionPane.ERROR_MESSAGE);
        } finally {
            IOUtils.closeQuietly(fw);
        }
    }

}

From source file:de.cebitec.readXplorer.util.GeneralUtils.java

/**
 * @param parent the parent component/*from  www .  j a  v a2 s.  c o m*/
 * @return Any text found in the clipboard. If none is found, an empty
 * String is returned.
 */
public static String getClipboardContents(Component parent) {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    String result = "";
    Transferable contents = clipboard.getContents(null);
    final boolean hasTransferableText = (contents != null)
            && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
    if (hasTransferableText) {
        try {
            result = (String) contents.getTransferData(DataFlavor.stringFlavor);
        } catch (UnsupportedFlavorException ex) {
            JOptionPane.showMessageDialog(parent, "Unsupported DataFlavor for clipboard copying.",
                    "Paste Error", JOptionPane.ERROR_MESSAGE);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(parent,
                    "IOException occured during recovering of text from clipboard.", "Paste Error",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
    return result;
}

From source file:cz.nn.copytables.gui.CopyTablesGUI.java

void showErrorPane(String title, String msg) {
    logger.error(msg);/*from  w ww.j a  v a  2s.c om*/
    JOptionPane pane = new JOptionPane(msg, JOptionPane.ERROR_MESSAGE);
    JDialog dialog = pane.createDialog("Application says: " + title);
    dialog.setAlwaysOnTop(true);
    dialog.setVisible(true);
}

From source file:com.redpill_linpro.libreoffice.LibreOfficeLauncherMacOSXImpl.java

@Override
public void launchLibreOffice(String cmisUrl, String repositoryId, String filePath, String webdavUrl) {

    Runtime rt = Runtime.getRuntime();
    try {/*from   w  ww .j av  a2  s . c o  m*/
        String params;
        if (null != webdavUrl && webdavUrl.length() > 0) {
            params = LibreOfficeLauncherHelper.generateLibreOfficeWebdavOpenUrl(webdavUrl);
        } else {
            params = LibreOfficeLauncherHelper.generateLibreOfficeCmisOpenUrl(cmisUrl, repositoryId, filePath);
        }
        StringBuffer cmd = new StringBuffer();
        try {
            String[] binaryLocations = { "/Applications/LibreOffice.app/Contents/MacOS/soffice" };
            cmd.append(binaryLocations[0] + " " + params);
            System.out.println("Command: " + cmd.toString());
            rt.exec(cmd.toString());

            System.out.println("Process started");
        } catch (IOException e) {
            JOptionPane.showMessageDialog(null, "Failed to start LibreOffice, commandline: " + cmd.toString(),
                    "Error", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }

    } catch (UnsupportedEncodingException e1) {
        JOptionPane.showMessageDialog(null, "Invalid URL for LibreOffice", "Error", JOptionPane.ERROR_MESSAGE);
        e1.printStackTrace();
    }
}

From source file:co.udea.edu.proyectointegrador.gr11.parqueaderoapp.view.stadistics.EstadisticaUI.java

private void iniciarGraficos() {
    try {//from w  ww .  java  2s . c  om
        chartTypeVehicle = controller.getChartToTypeVehicle(fechaInicio, fechaFin);
        chartTypeUser = controller.getChartToTypeUser(fechaInicio, fechaFin);
        chartHourOfDay = controller.getChartToHourOfDay(fechaInicio, fechaFin);

    } catch (BussinessException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:be.ac.ua.comp.scarletnebula.gui.keywizards.FinalNewKeyPage.java

@Override
protected void performAction(final KeyRecorder recorder) {
    recorder.keyname = keyname;/*from w w  w  .j  a v a 2 s . c  o m*/
    recorder.makeDefault = makeKeyDefault();

    (new SwingWorker<Exception, Object>() {
        @Override
        protected Exception doInBackground() throws Exception {
            try {
                provider.createKey(keyname, makeKeyDefault());
            } catch (final Exception e) {
                return e;
            }
            return null;
        }

        @Override
        public void done() {
            try {
                final Exception result = get();

                if (result != null) {
                    log.error("Could not create key", result);
                    JOptionPane.showMessageDialog(FinalNewKeyPage.this, result.getLocalizedMessage(),
                            "Error creating key", JOptionPane.ERROR_MESSAGE);
                }
            } catch (final Exception ignore) {
            }
        }
    }).execute();
}

From source file:edu.ku.brc.util.XMLChecksumUtil.java

/**
 * Returns whether the checksum in the file matched the checksum of the file.
 * @param file the File object to be checked
 * @return true if check sum matches, false if not.
 *//*from www. j av  a 2s.co  m*/
public static boolean checkSignature(final File file) {
    Properties checksumProps = new Properties();
    File checksumFile = XMLHelper.getConfigDir(checksumFileName);
    if (checksumFile.exists()) {
        try {
            checksumProps.load(new FileInputStream(checksumFile));
            return checkSignature(checksumProps, file);

        } catch (IOException ex) {
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(XMLChecksumUtil.class, ex);
            throw new RuntimeException(
                    "Couldn't locate Checksum file [" + checksumFile.getAbsolutePath() + "]");
        }
    } else {
        JOptionPane.showMessageDialog(null, getResourceString("CHECKSUM_MSG"),
                getResourceString("CHECKSUM_TITLE"), JOptionPane.ERROR_MESSAGE);
        System.exit(0);
    }
    return false;
}

From source file:licenceexecuter.LicenceExecuter.java

private void run() throws Throwable {
    Date atualDate = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    ObKeyExecuter obKey = ControllerKey.decrypt(properties.getProperty("key"));
    if (atualDate.before(obKey.getDataLicenca())) {
        JOptionPane.showMessageDialog(null, "SUA LICENA INICIA DIA: " + sdf.format(obKey.getDataLicenca()),
                "ATENO", JOptionPane.ERROR_MESSAGE);
        return;//ww w  .j  a  v  a2s.  c o  m
    }

    if (atualDate.after(obKey.getUltimaDataVerificada())) {
        try {
            if (atualDate.before(obKey.getDataValidade())) {
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(obKey.getDataValidade());
                calendar.add(Calendar.DAY_OF_MONTH, -6);
                if (atualDate.after(calendar.getTime())) {
                    String msg = String.format(
                            "SUA LICENA VENCE NO DIA %s ENTRE COM A NOVA CHAVE OU CONTINUE.",
                            sdf.format(obKey.getDataValidade()));
                    JDialogRegister jDialogRegister = new JDialogRegister(msg);
                    jDialogRegister.setVisible(true);
                    if (jDialogRegister.getNewKey() != null && !jDialogRegister.getNewKey().isEmpty()) {
                        ObKeyExecuter ob2 = register(jDialogRegister.getNewKey());
                        obKey = ob2 == null ? obKey : ob2;
                    }
                }
            } else {
                String msg = String.format(
                        "SUA LICENA VENCEU NO DIA %s ENTRE COM A NOVA CHAVE OU CONTINUE PARA SAIR.",
                        sdf.format(obKey.getDataValidade()));
                JDialogRegister jDialogRegister = new JDialogRegister(msg);
                jDialogRegister.setVisible(true);
                if (jDialogRegister.getNewKey() != null && !jDialogRegister.getNewKey().isEmpty()) {
                    ObKeyExecuter ob2 = register(jDialogRegister.getNewKey());
                    if (ob2 == null) {
                        return;
                    }
                    obKey = ob2;
                } else {
                    return;
                }
            }
            executeProgram(obKey);
        } finally {
            obKey.setUltimaDataVerificada(atualDate);
            updateKey(obKey);
        }
    } else {
        JOptionPane.showMessageDialog(null, "POSS?VEL ALTERAO NO RELGIO DO SISTEMA! VERIFIQUE",
                "ATENO", JOptionPane.ERROR_MESSAGE);
    }

}