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:EditorPaneExample1.java
public EditorPaneExample1() { super("JEditorPane Example 1"); pane = new JEditorPane(); pane.setEditable(false); // Read-only getContentPane().add(new JScrollPane(pane), "Center"); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(4, 4)); JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, "West"); textField = new JTextField(32); panel.add(textField, "Center"); getContentPane().add(panel, "South"); // Change page based on text field textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String url = textField.getText(); try { // Try to display the page pane.setPage(url);//from w w w . j a va 2 s . co m } catch (IOException e) { JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url }, "File Open Error", JOptionPane.ERROR_MESSAGE); } } }); }
From source file:com.a544jh.kanamemory.ui.ProfileChooserPanel.java
public void populateList() { listmodel = new DefaultListModel<>(); ArrayList<String> names; try {//from w ww. j a va 2s . co m names = JsonFileReader.ProfilesList("profiles"); } catch (FileNotFoundException ex) { System.out.println("Profiles file not found. A new one will be created."); names = new ArrayList<>(); } catch (JSONException ex) { JOptionPane.showMessageDialog(this, ex.getMessage() + "\nFix or delete the profiles file.", "Profiles file malformed", JOptionPane.ERROR_MESSAGE); System.exit(0); names = new ArrayList<>(); } for (String string : names) { listmodel.addElement(string); } profilesList.setModel(listmodel); }
From source file:heimerdinger.HeimerdingerFrame.java
/** * Creates new form HeimerdingerFrame//w ww. j a v a2 s . c o m */ public HeimerdingerFrame() { initComponents(); if (!connectDB()) { JOptionPane.showMessageDialog(null, "Could not connect to database. Check LOG for more infomation.", "ERROR", JOptionPane.ERROR_MESSAGE); System.exit(0); } this.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (this.getWidth() / 2), (Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (this.getHeight() / 2)); initLastSession(); }
From source file:com.willwinder.universalgcodesender.utils.GUIHelpers.java
/** * Displays an error message to the user. * @param errorMessage message to display in the dialog. * @param modal toggle whether the message should block or fire and forget. */// ww w.j av a 2s . c o m public static void displayErrorDialog(final String errorMessage, boolean modal) { if (StringUtils.isEmpty(errorMessage)) { LOGGER.warning("Something tried to display an error message with an empty message: " + ExceptionUtils.getStackTrace(new Throwable())); return; } Runnable r = () -> { //JOptionPane.showMessageDialog(new JFrame(), errorMessage, // Localization.getString("error"), JOptionPane.ERROR_MESSAGE); NarrowOptionPane.showNarrowDialog(250, errorMessage.replaceAll("\\.\\.", "\\."), Localization.getString("error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); }; if (modal) { r.run(); } else { java.awt.EventQueue.invokeLater(r); } }
From source file:com.compomics.cell_coord.gui.controller.CellCoordController.java
/** * Initialize main controller./*from w w w. j a va 2 s . c o m*/ */ public void init() { //set uncaught exception handler Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { LOG.error(e.getMessage(), e); showMessage("Unexpected error: " + e.getMessage() + ", application will exit", "unexpected error", JOptionPane.ERROR_MESSAGE); // exit the application System.exit(1); } }); // new frame instance cellCoordFrame = new CellCoordFrame(); cellCoordFrame.setVisible(true); // at starter, show main panel with logo getCardLayout().first(cellCoordFrame.getTopPanel()); onCardSwitch(); // init child controllers loadTracksController.init(); initMainFrame(); }
From source file:Main.java
public void actionPerformed(ActionEvent e) { String menuText = ((JMenuItem) e.getSource()).getText(); int messageType = JOptionPane.INFORMATION_MESSAGE; if (menuText.equals("Information")) { messageType = JOptionPane.INFORMATION_MESSAGE; } else if (menuText.equals("Warning")) { messageType = JOptionPane.WARNING_MESSAGE; } else if (menuText.equals("Error")) { messageType = JOptionPane.ERROR_MESSAGE; } else if (menuText.equals("Plain")) { messageType = JOptionPane.PLAIN_MESSAGE; }/* ww w . j a va 2s . co m*/ JOptionPane.showMessageDialog(myFrame, "This is message dialog box of type: " + menuText, menuText + " Message", messageType); }
From source file:net.sf.firemox.tools.MSaveDeck.java
/** * Saves deck to ASCII file from specified staticTurnLists. This new file will * contain the card names sorted in alphabetical order with their quantity * with this format :<br>/*from w w w .j a v a2 s .c o m*/ * <i>card's name </i> <b>; </b> <i>qty </i> <b>\n </b> <br> * * @param fileName * Name of new file. * @param names * ListModel of card names. * @param parent * the parent * @return true if the current deck has been correctly saved. false otherwise. */ public static boolean saveDeck(String fileName, MListModel<MCardCompare> names, JFrame parent) { PrintWriter outStream = null; try { // create the deckfile. If it was already existing, it would be scrathed. outStream = new PrintWriter(new FileOutputStream(fileName)); } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog(parent, "Cannot create/modify the specified deck file:" + fileName + "\n" + ex.getMessage(), "File creation problem", JOptionPane.ERROR_MESSAGE); return false; } Object[] namesArray = names.toArray(); MCardCompare[] cards = new MCardCompare[namesArray.length]; System.arraycopy(namesArray, 0, cards, 0, namesArray.length); // sorts names Arrays.sort(cards, new MCardCompare()); // writes lines corresponding to this format : "card;quantity\n" for (int i = 0; i < cards.length; i++) { outStream.println(cards[i].toString()); } IOUtils.closeQuietly(outStream); // successfull deck save JOptionPane.showMessageDialog(parent, "Saving file " + fileName.substring(fileName.lastIndexOf("/") + 1) + " was successfully completed.", "Save success", JOptionPane.INFORMATION_MESSAGE); return true; }
From source file:au.org.ala.delta.intkey.ui.DirectiveAction.java
@Override public void actionPerformed(ActionEvent e) { try {/*from w ww . j av a2s . c om*/ _directive.parseAndProcess(_context, null); } catch (IntkeyDirectiveParseException ex) { ex.printStackTrace(); String msg = ex.getMessage(); JOptionPane.showMessageDialog(UIUtils.getMainFrame(), msg, "Error", JOptionPane.ERROR_MESSAGE); Logger.error(msg); } catch (Exception ex) { ex.printStackTrace(); String msg = MessageFormat.format(UIUtils.getResourceString("ErrorWhileProcessingCommand.error"), StringUtils.join(_directive.getControlWords(), " ").toUpperCase(), ex.getMessage()); JOptionPane.showMessageDialog(UIUtils.getMainFrame(), msg, "Error", JOptionPane.ERROR_MESSAGE); Logger.error(msg); Logger.error(ex); } }
From source file:com.sec.ose.osi.sdk.protexsdk.project.ProjectAPIWrapper.java
public static boolean checkConnectToServer() { if (ProtexSDKAPIManager.getProjectAPI() == null) { JOptionPane.showMessageDialog(null, "Can't connect server to refresh project list", "Connection Error", JOptionPane.ERROR_MESSAGE); return false; }//w w w .j a va2s.c o m return true; }
From source file:com.leclercb.taskunifier.gui.main.Main.java
public static void main(final String[] args) throws SingleInstanceException { try {// w w w . jav a 2s.c o m MainSplashScreen.getInstance().show(); MainSplashScreen.getInstance().update("Loading..."); initialize(); loadDeveloperMode(); MainSplashScreen.getInstance().update("Loading resource folder..."); loadResourceFolder(); MainSplashScreen.getInstance().update("Loading init settings..."); loadInitSettings(); MainSplashScreen.getInstance().update("Loading data folder..."); loadDataFolder(); MainSplashScreen.getInstance().update("Loading plugins folder..."); loadPluginsFolder(); MainSplashScreen.getInstance().update("Check single instance..."); if (!checkSingleInstance(args)) { secondaryMain(args); throw new SingleInstanceException("Another instance of TaskUnifier is running"); } MainSplashScreen.getInstance().update("Loading loggers..."); MainLoadLoggers.loadLoggers(); MainSplashScreen.getInstance().update("Loading exception handler..."); loadUncaughtExceptionHandler(); MainSplashScreen.getInstance().update("Loading settings..."); loadSettings(); MainSplashScreen.getInstance().update("Loading time zone..."); loadTimeZone(); MainSplashScreen.getInstance().update("Loading user id..."); loadUserId(); MainSplashScreen.getInstance().update("Loading user folder..."); loadUserFolder(); MainSplashScreen.getInstance().update("Loading backup folder..."); loadBackupFolder(); MainSplashScreen.getInstance().update("Updating settings..."); PREVIOUS_VERSION = SettingsVersion.updateSettings(); MainSplashScreen.getInstance().update("Loading user settings..."); loadUserSettings(); MainSplashScreen.getInstance().update("Updating user settings..."); UserSettingsVersion.updateSettings(); MainSplashScreen.getInstance().update("Loading logger levels..."); MainLoadLoggers.loadLoggerLevels(); loadProxies(); MainSplashScreen.getInstance().update("Loading locale..."); loadLocale(); //MainSplashScreen.getInstance().update("Checking pro license..."); loadProVersion(); MainSplashScreen.getInstance().update("Loading models..."); loadModels(); MainSplashScreen.getInstance().update("Loading look and feel..."); loadLookAndFeel(); MainSplashScreen.getInstance().update("Loading plugins..."); OUTDATED_PLUGINS = loadApiPlugins(); MainSplashScreen.getInstance().update("Loading synchronizer..."); loadSynchronizer(); MainSplashScreen.getInstance().update("Loading shutdown hooks..."); loadShutdownHooks(); MainSplashScreen.getInstance().update("Loading protocol handlers..."); loadCustomProtocolHandlers(); VERSION_UPDATED = !Constants.getVersion().equals(PREVIOUS_VERSION); Constants.initialize(); ACTION_SUPPORT.fireActionPerformed(0, "AFTER_START"); } catch (SingleInstanceException e) { throw e; } catch (Exception e) { MainSplashScreen.getInstance().show(); GuiLogger.getLogger().log(Level.SEVERE, e.getMessage(), e); JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); return; } ProcessUtils.invokeLater(new MainSwingRunnable(args)); }