Example usage for javax.swing JOptionPane showMessageDialog

List of usage examples for javax.swing JOptionPane showMessageDialog

Introduction

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

Prototype

public static void showMessageDialog(Component parentComponent, Object message, String title, int messageType)
        throws HeadlessException 

Source Link

Document

Brings up a dialog that displays a message using a default icon determined by the messageType parameter.

Usage

From source file:au.org.ala.delta.intkey.ui.DirectiveAction.java

@Override
public void actionPerformed(ActionEvent e) {
    try {//  www . j  a  va 2 s .  com
        _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.leclercb.taskunifier.gui.main.Main.java

public static void main(final String[] args) throws SingleInstanceException {
    try {/*from   w  ww  .j a v  a2s .  com*/
        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));
}

From source file:com.dragoniade.deviantart.deviation.SearchResources.java

public List<Deviation> search(ProgressDialog progress, Collection collection) {
    if (user == null) {
        throw new IllegalStateException("You must set the user before searching.");
    }/*from   w w w  .j  a v  a  2 s. c  o  m*/
    if (search == null) {
        throw new IllegalStateException("You must set the search type before searching.");
    }
    JOptionPane.showMessageDialog(owner, "The resource Searcher hasn't been implemented yet.",
            "Not implemented yet", JOptionPane.WARNING_MESSAGE);
    return null;
}

From source file:com.dragoniade.deviantart.deviation.SearchHelloWorld.java

public List<Deviation> search(ProgressDialog progress, Collection collection) {
    if (user == null) {
        throw new IllegalStateException("You must set the user before searching.");
    }//w w  w  .  j  av a 2  s . co  m
    if (search == null) {
        throw new IllegalStateException("You must set the search type before searching.");
    }
    JOptionPane.showMessageDialog(owner,
            "<html>Hello world!<br/> Because there has to be an Hello World script everywhere :)</html>", user,
            JOptionPane.WARNING_MESSAGE);
    return null;
}

From source file:dialog.DialogFunctionUser.java

private void actionAddUserNoController() {
    if (!isValidData()) {
        return;/*  w ww  . ja va  2s. c  o  m*/
    }
    if (isExistUsername(tfUsername.getText())) {
        JOptionPane.showMessageDialog(null, "Username  tn ti", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    String username = tfUsername.getText();
    String fullname = tfFullname.getText();
    String password = new String(tfPassword.getPassword());
    password = LibraryString.md5(password);
    int role = cbRole.getSelectedIndex();
    User objUser;
    if (mAvatar != null) {
        objUser = new User(UUID.randomUUID().toString(), username, password, fullname, role,
                new Date(System.currentTimeMillis()), mAvatar.getPath());
        String fileName = FilenameUtils.getBaseName(mAvatar.getName()) + "-" + System.nanoTime() + "."
                + FilenameUtils.getExtension(mAvatar.getName());
        Path source = Paths.get(mAvatar.toURI());
        Path destination = Paths.get("files/" + fileName);
        try {
            Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
        } catch (IOException ex) {
            Logger.getLogger(DialogFunctionRoom.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        objUser = new User(UUID.randomUUID().toString(), username, password, fullname, role,
                new Date(System.currentTimeMillis()), "");
    }
    if ((new ModelUser()).addItem(objUser)) {
        ImageIcon icon = new ImageIcon(getClass().getResource("/images/ic_success.png"));
        JOptionPane.showMessageDialog(this.getParent(), "Thm thnh cng", "Success",
                JOptionPane.INFORMATION_MESSAGE, icon);
    } else {
        JOptionPane.showMessageDialog(this.getParent(), "Thm tht bi", "Fail",
                JOptionPane.ERROR_MESSAGE);
    }
    this.dispose();
}

From source file:com.webcrawler.WebCrawlerMain.java

@Override
public void showErrorMessageDialog(String message, String dialogHeader) {
    JOptionPane.showMessageDialog(this, message, dialogHeader, JOptionPane.ERROR_MESSAGE);
}

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;
    }/*from  w  ww. jav a 2s. c  o  m*/

    JOptionPane.showMessageDialog(myFrame, "This is message dialog box of type: " + menuText,
            menuText + " Message", messageType);
}

From source file:com.sec.ose.osi.thread.job.init.BeforeLoginTaskThread.java

private void connectIdentificationDB() {
    // DB Connection
    if (!IdentificationDBManager.connectToDB()) {
        JOptionPane.showMessageDialog(null, "Can't connect to Identification DB", "disable Identification DB",
                JOptionPane.ERROR_MESSAGE);
        log.debug("Can't connect to Identification DB");
    }//from w w  w  .  j  a v a  2s  .c  o m
}

From source file:com.portmods.handlers.crackers.dictionary.Wordlist.java

@Override
public void run() {

    try {/* w ww.java2 s  . c om*/

        System.out.println("Loading Dictionary");

        InputStream fileStream = null;

        if (config.getUseCustomDictionary()) {

            try {

                fileStream = new FileInputStream(config.getCustomDictionary());

            } catch (Exception e) {

                JOptionPane.showMessageDialog(null, e, "Error with Dictonary File.", JOptionPane.ERROR_MESSAGE);
                System.exit(1);

            }

        } else {

            fileStream = Main.class.getResourceAsStream("/com/portmods/files/words.txt");

        }

        BufferedReader reader = new BufferedReader(new InputStreamReader(fileStream, "UTF-8"));

        /* declaring storage list */
        wordlist = new ArrayList<String>();
        String text = "";

        String line = reader.readLine();

        while (line != null) //wait for ever
        {
            text = line;
            line = reader.readLine();
            if (text.length() < 9 && text.length() > 2) {
                wordlist.add(text);
            }

        }

    } catch (UnsupportedEncodingException e) {

        System.out.println("Error Loading Dictionary");

    } catch (IOException e) {

        System.out.println("Error Loading Dictionary");

    }

    System.out.println("Finished Loading Dictionary");
    System.out.println("Rule 1 : Do nothing to word");

    for (String s : wordlist) {

        String hash = UnixCrypt.crypt(s, "aa");

        for (User u : pw.getUsers()) {

            if (u.getHash().equals(hash)) {

                System.out.println("Found password " + s + " for user " + u.getUserName());
                fp.addPassword(u.getUserName(), s);

            }

        }

    }

    System.out.println("Rule 2 : Toggle case of every character");
    /* Chaning word characters one at time lowerecase to Uppercase and vice Veser. */
    for (String s : wordlist) {
        for (int i = 0; i < s.length(); i++) {
            char C = s.charAt(i); //take character from the word
            StringBuilder sbuilder = new StringBuilder(s); //word we want to inject the character into
            if (Character.isUpperCase(C)) {
                sbuilder.setCharAt(i, Character.toLowerCase(C)); //changing the character to lowercase

            } else if (Character.isLowerCase(C)) {
                sbuilder.setCharAt(i, Character.toUpperCase(C)); // change to uppercase
            }

            String hash = UnixCrypt.crypt(sbuilder.toString(), "aa");

            for (User u : pw.getUsers()) {

                if (u.getHash().equals(hash)) {

                    System.out
                            .println("Found password " + sbuilder.toString() + " for user " + u.getUserName());
                    fp.addPassword(u.getUserName(), sbuilder.toString());

                }

            }

        }

    }

    System.out.println("Rule 3 : adding random numbers and leters into the word");
    /* generating number and adding to the words*/
    for (String s : wordlist) {
        for (int i = 0; i < 10; i++) {
            StringBuilder sb = new StringBuilder(s);
            sb.append(i); //add an integer to each word.

            String out = sb.toString();

            if (out.length() <= 8) {

                String hash = UnixCrypt.crypt(out, "aa");

                for (User u : pw.getUsers()) {

                    if (u.getHash().equals(hash)) {

                        System.out.println("Found password " + sb.toString() + " for user " + u.getUserName());
                        fp.addPassword(u.getUserName(), sb.toString());

                    }

                }

            }

        }

    }

    System.out.println("Rule 4: Toggle one charater at a time and replace a number");
    /* trying to toggle one charater at a time and replace a number*/
    for (String s : wordlist) {
        for (int j = 0; j < s.length(); j++) {
            for (int i = 0; i < 10; i++) {
                char C = s.charAt(j); //take character from the word
                StringBuilder sbuilder = new StringBuilder(s); //word we want to inject the character into
                if (Character.isAlphabetic(C)) {
                    sbuilder.deleteCharAt(j); //remove character
                    sbuilder.insert(j, i); // add digit

                    String hash = UnixCrypt.crypt(sbuilder.toString(), "aa");

                    for (User u : pw.getUsers()) {

                        if (u.getHash().equals(hash)) {

                            System.out.println(
                                    "Found password " + sbuilder.toString() + " for user " + u.getUserName());
                            fp.addPassword(u.getUserName(), sbuilder.toString());

                        }

                    }
                }

            }

            for (int x = 65; x < 123; x++) {
                char C1 = (char) x;

                char C = s.charAt(j); //take character from the word
                StringBuilder sbuilder = new StringBuilder(s); //word we want to inject the character into
                if (Character.isDigit(C)) {
                    sbuilder.setCharAt(j, C1);

                    String hash = UnixCrypt.crypt(sbuilder.toString(), "aa");

                    for (User u : pw.getUsers()) {

                        if (u.getHash().equals(hash)) {

                            System.out.println(
                                    "Found password " + sbuilder.toString() + " for user " + u.getUserName());
                            fp.addPassword(u.getUserName(), sbuilder.toString());

                        }

                    }

                }

            }

        }

    }

    System.out.println("Rule 5 : Adding random letters and numbers to the end");
    /* adding ascii values to a text string */

    for (String s : wordlist) {
        int x = 1;
        StringBuilder sb = new StringBuilder(s);
        for (int i = 33; i < 123; i++) {
            char L1 = (char) i;
            String out = sb.toString();

            String out1 = out + L1;

            if (out1.length() > 8) {

                break;

            } else {

                String hash = UnixCrypt.crypt(out1, "aa");

                for (User u : pw.getUsers()) {

                    if (u.getHash().equals(hash)) {

                        System.out.println("Found password " + out1 + " for user " + u.getUserName());
                        fp.addPassword(u.getUserName(), out1);

                    }

                }

            }

            for (int j = 33; j < 123; j++) {
                char L2 = (char) j;

                String out2 = out + L1 + L2;

                if (out2.length() > 8) {

                    break;

                } else {

                    String hash = UnixCrypt.crypt(out2, "aa");

                    for (User u : pw.getUsers()) {

                        if (u.getHash().equals(hash)) {

                            System.out.println("Found password " + out2 + " for user " + u.getUserName());
                            fp.addPassword(u.getUserName(), out2);

                        }

                    }

                }

                for (int k = 33; k < 123; k++) {
                    char L3 = (char) k;

                    String out3 = out + L1 + L2 + L3;

                    if (out3.length() > 8) {

                        break;

                    } else {

                        String hash = UnixCrypt.crypt(out3, "aa");

                        for (User u : pw.getUsers()) {

                            if (u.getHash().equals(hash)) {

                                System.out.println("Found password " + out3 + " for user " + u.getUserName());
                                fp.addPassword(u.getUserName(), out3);

                            }

                        }

                    }
                    for (int l = 33; l < 123; l++) {
                        char L4 = (char) l;

                        String out4 = out + L1 + L2 + L3 + L4;

                        if (out4.length() > 8) {

                            break;

                        } else {

                            String hash = UnixCrypt.crypt(out4, "aa");

                            for (User u : pw.getUsers()) {

                                if (u.getHash().equals(hash)) {

                                    System.out
                                            .println("Found password " + out4 + " for user " + u.getUserName());
                                    fp.addPassword(u.getUserName(), out4);

                                }

                            }

                        }
                    }
                }
            }
            if (out.length() < 8) {

            } else {

                System.out.println(out);
                break;
            }
        }
    }

    config.setDicModeFin(true);

}

From source file:org.obiba.onyx.jade.instrument.reichert.OraInstrumentRunner.java

@Override
public void initialize() {
    if (externalAppHelper.isSotfwareAlreadyStarted()) {
        JOptionPane.showMessageDialog(null, externalAppHelper.getExecutable()
                + " already lock for execution.  Please make sure that another instance is not running.",
                "Cannot start application!", JOptionPane.ERROR_MESSAGE);
        throw new RuntimeException("already lock for execution");
    }/* w  ww.  j  a  v  a  2  s.  c  o  m*/
    initializeParticipantData();
}