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:com._17od.upm.gui.MainWindow.java

public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {

            try {
                // Use the System look and feel
                Preferences.load();
                Translator.initialise();
                Double jvmVersion = new Double(System.getProperty("java.specification.version"));
                if (jvmVersion.doubleValue() < 1.4) {
                    JOptionPane.showMessageDialog(null, Translator.translate("requireJava14"),
                            Translator.translate("problem"), JOptionPane.ERROR_MESSAGE);
                    System.exit(1);
                } else {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    AppWindow = new MainWindow(applicationName);
                }/*from   ww w. j ava2s  .c om*/

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:com.adito.server.Main.java

/**
 * Entry point//w w w  . ja v  a  2 s.c om
 * 
 * @param args
 * @throws Throwable
 */
public static void main(String[] args) throws Throwable {

    // This is a hack to allow the Install4J installer to get the java
    // runtime that will be used
    if (args.length > 0 && args[0].equals("--jvmdir")) {
        System.out.println(SystemProperties.get("java.home"));
        System.exit(0);
    }
    useWrapper = System.getProperty("wrapper.key") != null;
    final Main main = new Main();
    ContextHolder.setContext(main);

    if (useWrapper) {
        WrapperManager.start(main, args);
    } else {
        Integer returnCode = main.start(args);
        if (returnCode != null) {
            if (main.gui) {
                if (main.startupException == null) {
                    main.startupException = new Exception("An exit code of " + returnCode + " was returned.");
                }
                try {
                    if (SystemProperties.get("os.name").toLowerCase().startsWith("windows")) {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    }
                } catch (Exception e) {
                }
                String mesg = main.startupException.getMessage() == null ? "No message supplied."
                        : main.startupException.getMessage();
                StringBuffer buf = new StringBuffer();
                int l = 0;
                char ch = ' ';
                for (int i = 0; i < mesg.length(); i++) {
                    ch = mesg.charAt(i);
                    if (l > 50 && ch == ' ') {
                        buf.append("\n");
                        l = 0;
                    } else {
                        if (ch == '\n') {
                            l = 0;
                        } else {
                            l++;
                        }
                        buf.append(ch);
                    }
                }
                mesg = buf.toString();
                final String fMesg = mesg;
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(null, fMesg, "Startup Error", JOptionPane.ERROR_MESSAGE);
                    }
                });
            }
            System.exit(returnCode.intValue());
        } else {
            Runtime.getRuntime().addShutdownHook(new Thread() {
                public void run() {
                    if (!main.shuttingDown) {
                        main.stop(0);
                    }
                }
            });
        }
    }
}

From source file:Main.java

public static void warnUser(Component parent, String message) {
    JOptionPane.showMessageDialog(parent, message, "Warning", JOptionPane.WARNING_MESSAGE);
}

From source file:latexstudio.editor.remote.DbxUtil.java

public static DbxClient getDbxClient() {
    String accessToken = (String) ApplicationSettings.Setting.DROPBOX_TOKEN.getValue();
    if (accessToken == null) {
        JOptionPane.showMessageDialog(null,
                "The authentication token has not been set.\n"
                        + "Please connect the application to your Dropbox account first!",
                "Dropbox authentication token not found", JOptionPane.ERROR_MESSAGE);
        return null;
    }/*from w w w .java2  s.c  o m*/
    return new DbxClient(getDbxConfig(), accessToken);
}

From source file:guiTool.Helper.java

public static final boolean checkInternet() {

    try {//www.j  a v  a  2s.  c o  m
        Socket socket = new Socket();
        InetSocketAddress add = new InetSocketAddress("www.google.com", 80);
        socket.connect(add, 3000);
        return true;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "The server or your internet connection could be down.",
                "connection test", JOptionPane.ERROR_MESSAGE);
        return false;
    }

}

From source file:Main.java

/**
 * Show an info window.//from  w w w. j a  va2  s  .  c  o m
 * @param message   The message to show.
 * @param parent   Parent component of this dialog.
 */
public static void info(String message, Component parent) {
    Toolkit.getDefaultToolkit().beep();
    JOptionPane.showMessageDialog(parent, message, "Info", JOptionPane.INFORMATION_MESSAGE);
}

From source file:Main.java

/**
 * Show an alert window.//from   w  ww . jav a2  s. c  om
 * @param message   The message to show.
 * @param parent   Parent component of this dialog.
 */
public static void error(String message, Component parent) {
    Toolkit.getDefaultToolkit().beep();
    JOptionPane.showMessageDialog(parent, message, "Alert", JOptionPane.ERROR_MESSAGE);
}

From source file:Main.java

/**
 * Show a warning window.//w ww .j  av a2 s  .c om
 * @param message   The message to show.
 * @param parent   Parent component of this dialog.
 */
public static void warning(String message, Component parent) {
    Toolkit.getDefaultToolkit().beep();
    JOptionPane.showMessageDialog(parent, message, "Warning", JOptionPane.WARNING_MESSAGE);
}

From source file:Main.java

private void displayGUI() {
    JOptionPane.showMessageDialog(null, getPanel(), "Output : ", JOptionPane.INFORMATION_MESSAGE);
}

From source file:Main.java

/** Pops up a message box, blocking the current thread. */
public static void pause(final String msg) {
    JOptionPane.showMessageDialog(null, msg, "VisBio", JOptionPane.PLAIN_MESSAGE);
}