List of usage examples for javax.swing JOptionPane ERROR_MESSAGE
int ERROR_MESSAGE
To view the source code for javax.swing JOptionPane ERROR_MESSAGE.
Click Source Link
From source file:com.edduarte.protbox.Protbox.java
public static void main(String... args) { // activate debug / verbose mode if (args.length != 0) { List<String> argsList = Arrays.asList(args); if (argsList.contains("-v")) { Constants.verbose = true;/*w w w.j ava 2 s .c o m*/ } } // use System's look and feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { // If the System's look and feel is not obtainable, continue execution with JRE look and feel } // check this is a single instance try { new ServerSocket(1882); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Another instance of Protbox is already running.\n" + "Please close the other instance first.", "Protbox already running", JOptionPane.ERROR_MESSAGE); System.exit(1); } // check if System Tray is supported by this operative system if (!SystemTray.isSupported()) { JOptionPane.showMessageDialog(null, "Your operative system does not support system tray functionality.\n" + "Please try running Protbox on another operative system.", "System tray not supported", JOptionPane.ERROR_MESSAGE); System.exit(1); } // add PKCS11 providers FileFilter fileFilter = new AndFileFilter(new WildcardFileFilter(Lists.newArrayList("*.config")), HiddenFileFilter.VISIBLE); File[] providersConfigFiles = new File(Constants.PROVIDERS_DIR).listFiles(fileFilter); if (providersConfigFiles != null) { for (File f : providersConfigFiles) { try { List<String> lines = FileUtils.readLines(f); String aliasLine = lines.stream().filter(line -> line.contains("alias")).findFirst().get(); lines.remove(aliasLine); String alias = aliasLine.split("=")[1].trim(); StringBuilder sb = new StringBuilder(); for (String s : lines) { sb.append(s); sb.append("\n"); } Provider p = new SunPKCS11(new ReaderInputStream(new StringReader(sb.toString()))); Security.addProvider(p); pkcs11Providers.put(p.getName(), alias); } catch (IOException | ProviderException ex) { if (ex.getMessage().equals("Initialization failed")) { ex.printStackTrace(); String s = "The following error occurred:\n" + ex.getCause().getMessage() + "\n\nIn addition, make sure you have " + "an available smart card reader connected before opening the application."; JTextArea textArea = new JTextArea(s); textArea.setColumns(60); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setSize(textArea.getPreferredSize().width, 1); JOptionPane.showMessageDialog(null, textArea, "Error loading PKCS11 provider", JOptionPane.ERROR_MESSAGE); System.exit(1); } else { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Error while setting up PKCS11 provider from configuration file " + f.getName() + ".\n" + ex.getMessage(), "Error loading PKCS11 provider", JOptionPane.ERROR_MESSAGE); } } } } // adds a shutdown hook to save instantiated directories into files when the application is being closed Runtime.getRuntime().addShutdownHook(new Thread(Protbox::exit)); // get system tray and run tray applet tray = SystemTray.getSystemTray(); SwingUtilities.invokeLater(() -> { if (Constants.verbose) { logger.info("Starting application"); } //Start a new TrayApplet object trayApplet = TrayApplet.getInstance(); }); // prompts the user to choose which provider to use ProviderListWindow.showWindow(Protbox.pkcs11Providers.keySet(), providerName -> { // loads eID token eIDTokenLoadingWindow.showPrompt(providerName, (returnedUser, returnedCertificateData) -> { user = returnedUser; certificateData = returnedCertificateData; // gets a password to use on the saved registry files (for loading and saving) final AtomicReference<Consumer<SecretKey>> consumerHolder = new AtomicReference<>(null); consumerHolder.set(password -> { registriesPasswordKey = password; try { // if there are serialized files, load them if they can be decoded by this user's private key final List<SavedRegistry> serializedDirectories = new ArrayList<>(); if (Constants.verbose) { logger.info("Reading serialized registry files..."); } File[] registryFileList = new File(Constants.REGISTRIES_DIR).listFiles(); if (registryFileList != null) { for (File f : registryFileList) { if (f.isFile()) { byte[] data = FileUtils.readFileToByteArray(f); try { Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, registriesPasswordKey); byte[] registryDecryptedData = cipher.doFinal(data); serializedDirectories.add(new SavedRegistry(f, registryDecryptedData)); } catch (GeneralSecurityException ex) { if (Constants.verbose) { logger.info("Inserted Password does not correspond to " + f.getName()); } } } } } // if there were no serialized directories, show NewDirectory window to configure the first folder if (serializedDirectories.isEmpty() || registryFileList == null) { if (Constants.verbose) { logger.info("No registry files were found: running app as first time!"); } NewRegistryWindow.start(true); } else { // there were serialized directories loadRegistry(serializedDirectories); trayApplet.repaint(); showTrayApplet(); } } catch (AWTException | IOException | GeneralSecurityException | ReflectiveOperationException | ProtboxException ex) { JOptionPane.showMessageDialog(null, "The inserted password was invalid! Please try another one!", "Invalid password!", JOptionPane.ERROR_MESSAGE); insertPassword(consumerHolder.get()); } }); insertPassword(consumerHolder.get()); }); }); }
From source file:es.tunelator.Start.java
/** * Bootstraps the application, creates and shows the user interface * @param args// w ww. ja v a2 s . c o m */ public static void main(String[] args) { MainFrame frame = null; try { // LogFactory.getFactory().setAttribute(LogFactoryImpl.LOG_PROPERTY, // Log4JLogger.class.getName()); // PropertyConfigurator.configure(Start.class.getClassLoader(). // getResource("log4j.properties")); // Set log level as configured at the application parameters Logger.setLogThreshold(AppParameters.getParams().getProperty("log.threshold", AppParameters.LOG_ERROR)); // If the language of the default locale is not supported revert to english if (!isLocaleSupported()) { Locale.setDefault(new Locale("en", "", "")); } else { Locale.setDefault(new Locale(Locale.getDefault().getLanguage(), "", "")); } // Log application startup Logger.logInfo(Start.class, Resourcer.getString(null, "log.info.startup")); // To set up the Look and Feel UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows." + "WindowsLookAndFeel"); frame = new MainFrame(); frame.setVisible(true); frame.correctTabStatus(); // To change the Look and Feel. To be included as an option some day... // UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk."+ // "GTKLookAndFeel"); // SwingUtilities.updateComponentTreeUI(frame); // frame.pack(); } catch (Exception e) { Logger.logFatal(Start.class, e); if (frame != null) { frame.showErrorMessage(Resourcer.getString(null, "error.internal")); frame.dispose(); } else { try { JOptionPane.showMessageDialog(null, Resourcer.getString(Start.class, "error.internal"), Resourcer.getString(Start.class, "error.title"), JOptionPane.ERROR_MESSAGE); } catch (Exception e2) { String message = ""; // This is the last resort to give a localized message // As I'm spanish :-), we give a spanish message if it's // the default language, and an english one otherwise. if (Locale.getDefault().getLanguage().equals(new Locale("es", "", "").getLanguage())) { message = message_es; } else { message = message_en; } JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE); } } System.exit(1); } catch (InternalError e) { Logger.logFatal(Start.class, e); if (frame != null) { frame.showErrorMessage(Resourcer.getString(null, "error.internal")); frame.dispose(); } else { try { JOptionPane.showMessageDialog(null, Resourcer.getString(Start.class, "error.internal"), Resourcer.getString(Start.class, "error.title"), JOptionPane.ERROR_MESSAGE); } catch (Exception e2) { String message = ""; // This is the last resort to give a localized message // As I'm spanish :-), we give a spanish message if it's // the default language, and an english one otherwise. if (Locale.getDefault().getLanguage().equals(new Locale("es", "", "").getLanguage())) { message = message_es; } else { message = message_en; } JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE); } } System.exit(1); } }
From source file:appmain.AppMain.java
public static void main(String[] args) { try {/* ww w.ja va 2 s . co m*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.put("OptionPane.yesButtonText", "Igen"); UIManager.put("OptionPane.noButtonText", "Nem"); } catch (Exception ex) { ex.printStackTrace(); } try { AppMain app = new AppMain(); app.init(); File importFolder = new File(DEFAULT_IMPORT_FOLDER); if (!importFolder.isDirectory() || !importFolder.exists()) { JOptionPane.showMessageDialog(null, "Az IMPORT mappa nem elrhet!\n" + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: " + importFolder.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); return; } File exportFolder = new File(DEFAULT_EXPORT_FOLDER); if (!exportFolder.isDirectory() || !exportFolder.exists()) { JOptionPane.showMessageDialog(null, "Az EXPORT mappa nem elrhet!\n" + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: " + exportFolder.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); return; } List<File> xmlFiles = app.getXMLFiles(importFolder); if (xmlFiles == null || xmlFiles.isEmpty()) { JOptionPane.showMessageDialog(null, "Nincs beolvasand XML fjl!\n" + "Mappa: " + importFolder.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); return; } StringBuilder fileList = new StringBuilder(); xmlFiles.stream().forEach(xml -> fileList.append("\n").append(xml.getName())); int ret = JOptionPane.showConfirmDialog(null, "Beolvassra elksztett fjlok:\n" + fileList + "\n\nIndulhat a feldolgozs?", "Megtallt XML fjlok", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret == JOptionPane.OK_OPTION) { String csvName = "tranzakcio_lista_" + df.format(new Date()) + "_" + System.currentTimeMillis() + ".csv"; File csv = new File(DEFAULT_EXPORT_FOLDER + "/" + csvName); app.writeCSV(csv, Arrays.asList(app.getHeaderLine())); xmlFiles.stream().forEach(xml -> { List<String> lines = app.readXMLData(xml); if (lines != null) app.writeCSV(csv, lines); }); if (csv.isFile() && csv.exists()) { JOptionPane.showMessageDialog(null, "A CSV fjl sikeresen elllt!\n" + "Fjl: " + csv.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); app.openFile(csv); } } else { JOptionPane.showMessageDialog(null, "Feldolgozs megszaktva!", "Informci", JOptionPane.INFORMATION_MESSAGE); } } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Nem kezelt kivtel!\n" + ExceptionUtils.getStackTrace(ex), "Hiba", JOptionPane.ERROR_MESSAGE); } }
From source file:com.projity.pm.graphic.gantt.Main.java
public static void main(String[] args) { System.setProperty("com.apple.mrj.application.apple.menu.about.name", Environment.getStandAlone() ? "OpenProj" : "Project-ON-Demand"); System.setProperty("apple.laf.useScreenMenuBar", "true"); Locale.setDefault(ConfigurationFile.getLocale()); HashMap opts = ApplicationStartupFactory.extractOpts(args); String osName = System.getProperty("os.name").toLowerCase(); if (osName.startsWith("linux")) { String javaExec = ConfigurationFile.getRunProperty("JAVA_EXE"); //check jvm String javaVersion = System.getProperty("java.version"); if (Environment.compareJavaVersion(javaVersion, "1.5") < 0) { String message = Messages.getStringWithParam("Text.badJavaVersion", javaVersion); if (javaExec != null && javaExec.length() > 0) message += "\n" + Messages.getStringWithParam("Text.javaExecutable", new Object[] { javaExec, "JAVA_EXE", "$HOME/.openproj/run.conf" }); if (!opts.containsKey("silentlyFail")) JOptionPane.showMessageDialog(null, message, Messages.getContextString("Title.ProjityError"), JOptionPane.ERROR_MESSAGE); System.exit(64);/*from w w w . ja va 2 s. c om*/ } String javaVendor = System.getProperty("java.vendor"); if (javaVendor == null || !(javaVendor.startsWith("Sun") || javaVendor.startsWith("IBM"))) { String message = Messages.getStringWithParam("Text.badJavaVendor", javaVendor); if (javaExec != null && javaExec.length() > 0) message += "\n" + Messages.getStringWithParam("Text.javaExecutable", new Object[] { javaExec, "JAVA_EXE", "$HOME/.openproj/run.conf" }); if (!opts.containsKey("silentlyFail")) JOptionPane.showMessageDialog(null, message, Messages.getContextString("Title.ProjityError"), JOptionPane.ERROR_MESSAGE); System.exit(64); } } boolean newLook = false; // HashMap opts = ApplicationStartupFactory.extractOpts(args); // allow setting menu look on command line - primarily for testing or webstart args log.info(opts); // newLook = opts.get("menu") == null; Environment.setNewLook(newLook); // if (!Environment.isNewLaf()) { // try { // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // } catch (Exception e) { // } // } ApplicationStartupFactory startupFactory = new ApplicationStartupFactory(opts); //put before to initialize standalone flag mainFrame = new MainFrame(Messages.getContextString("Text.ApplicationTitle"), null, null); boolean doWelcome = true; // to do see if project param exists in args startupFactory.instanceFromNewSession(mainFrame, doWelcome); }
From source file:fll.subjective.SubjectiveFrame.java
public static void main(final String[] args) { LogUtils.initializeLogging();/*from w w w.j a v a 2 s. c o m*/ Thread.setDefaultUncaughtExceptionHandler(new GuiExceptionHandler()); // Use cross platform look and feel so that things look right all of the // time try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (final ClassNotFoundException e) { LOGGER.warn("Could not find cross platform look and feel class", e); } catch (final InstantiationException e) { LOGGER.warn("Could not instantiate cross platform look and feel class", e); } catch (final IllegalAccessException e) { LOGGER.warn("Error loading cross platform look and feel", e); } catch (final UnsupportedLookAndFeelException e) { LOGGER.warn("Cross platform look and feel unsupported?", e); } try { final SubjectiveFrame frame = new SubjectiveFrame(); frame.addWindowListener(new WindowAdapter() { @Override @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK") public void windowClosing(final WindowEvent e) { System.exit(0); } @Override @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK") public void windowClosed(final WindowEvent e) { System.exit(0); } }); // should be able to watch for window closing, but hidden works frame.addComponentListener(new ComponentAdapter() { @Override @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK") public void componentHidden(final ComponentEvent e) { System.exit(0); } }); GraphicsUtils.centerWindow(frame); frame.setVisible(true); frame.promptForFile(); } catch (final Throwable e) { JOptionPane.showMessageDialog(null, "Unexpected error: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); LOGGER.fatal("Unexpected error", e); System.exit(1); } }
From source file:kevin.gvmsgarch.App.java
public static void main(String[] args) throws HttpException, IOException, ParserConfigurationException, SAXException, XPathExpressionException, JSONException, InterruptedException { System.out.println("Google Voice Message Archiver"); System.out.println("Copyright (C) 2013 Kevin Carter"); System.out.println("This program comes with ABSOLUTELY NO WARRANTY"); System.out.println("This is free software, and you are welcome to redistribute it"); System.out.println("under certain conditions. See the LICENSE file or"); System.out.println("http://www.gnu.org/licenses/gpl-3.0.txt for details"); try {/*from www . j av a 2s . com*/ HttpClient c = new HttpClient(); String userName = getUserName(); String password = getPassword(); int locationChosenIndex = JOptionPane.CLOSED_OPTION; if (password != null) { locationChosenIndex = JOptionPane.showOptionDialog(null, "Message source", "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, Worker.ListLocation.values(), Worker.ListLocation.inbox); } if (locationChosenIndex != JOptionPane.CLOSED_OPTION) { int modeChosenIndex = 0; Worker.ArchiveMode modeChosen = null; Worker.ListLocation location = Worker.ListLocation.values()[locationChosenIndex]; Worker.ArchiveMode[] availableModes = location.getAllowedModes(); if (availableModes.length == 1) { modeChosen = availableModes[0]; } else { modeChosenIndex = JOptionPane.showOptionDialog(null, "Operation mode", "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, availableModes, Worker.ArchiveMode.archive); if (modeChosenIndex != JOptionPane.CLOSED_OPTION) { modeChosen = availableModes[modeChosenIndex]; } } ContactFilter filter = null; if (modeChosenIndex != JOptionPane.CLOSED_OPTION && locationChosenIndex != JOptionPane.CLOSED_OPTION) { filter = buildFilter(); } if (modeChosenIndex != JOptionPane.CLOSED_OPTION && locationChosenIndex != JOptionPane.CLOSED_OPTION && filter != null && areYouSure(modeChosen, location, filter)) { assert modeChosen != null : "ZOMG"; String authToken = getToken(userName, password); String rnrse = getRnrse(authToken); final ProgressMonitor pm = new ProgressMonitor(null, "Working", "", 0, App.parseMsgsLeft(extractInboxJson(authToken, location, 1))); pm.setMillisToDecideToPopup(0); pm.setMillisToPopup(0); Worker worker = new Worker(authToken, rnrse, pm, modeChosen, location, filter); worker.addPropertyChangeListener(new ProgressPropertyChangeListener(pm)); pm.setProgress(0); worker.execute(); } } } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE); } }
From source file:fll.scheduler.SchedulerUI.java
public static void main(final String[] args) { LogUtils.initializeLogging();/*from w w w . j a va2 s . c om*/ Thread.setDefaultUncaughtExceptionHandler(new GuiExceptionHandler()); // Use cross platform look and feel so that things look right all of the // time try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (final ClassNotFoundException e) { LOGGER.warn("Could not find cross platform look and feel class", e); } catch (final InstantiationException e) { LOGGER.warn("Could not instantiate cross platform look and feel class", e); } catch (final IllegalAccessException e) { LOGGER.warn("Error loading cross platform look and feel", e); } catch (final UnsupportedLookAndFeelException e) { LOGGER.warn("Cross platform look and feel unsupported?", e); } try { final SchedulerUI frame = new SchedulerUI(); frame.addWindowListener(new WindowAdapter() { @Override @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK") public void windowClosing(final WindowEvent e) { System.exit(0); } @Override @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK") public void windowClosed(final WindowEvent e) { System.exit(0); } }); // should be able to watch for window closing, but hidden works frame.addComponentListener(new ComponentAdapter() { @Override @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK") public void componentHidden(final ComponentEvent e) { System.exit(0); } }); GraphicsUtils.centerWindow(frame); frame.setVisible(true); } catch (final Exception e) { LOGGER.fatal("Unexpected error", e); JOptionPane.showMessageDialog(null, "An unexpected error occurred. Please send the log file and a description of what you were doing to the developer. Error message: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:Main.java
public static void showErrorMessage(Component parent, Object errMsg) { JOptionPane.showMessageDialog(parent, errMsg, "Error", JOptionPane.ERROR_MESSAGE); }
From source file:Main.java
public static final void alert(Component component, String title, String msg) { JOptionPane.showMessageDialog(component, msg, title, JOptionPane.ERROR_MESSAGE); }
From source file:Main.java
public static void showErrorMessage(Component parentComponent, String mensagem) { JOptionPane.showMessageDialog(parentComponent, mensagem, "Erro", JOptionPane.ERROR_MESSAGE); }