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:ProgressMonitorInputExample.java

public ProgressMonitorInputExample(String filename) {
    ProgressMonitorInputStream monitor;
    try {/*  ww  w.  jav  a2s . c o  m*/
        monitor = new ProgressMonitorInputStream(null, "Loading " + filename, new FileInputStream(filename));
        while (monitor.available() > 0) {
            byte[] data = new byte[38];
            monitor.read(data);
            System.out.write(data);
        }
    } catch (FileNotFoundException e) {
        JOptionPane.showMessageDialog(null, "Unable to find file: " + filename, "Error",
                JOptionPane.ERROR_MESSAGE);
    } catch (IOException e) {
        ;
    }
}

From source file:de.erdesignerng.visual.MessagesHelper.java

public static void displayInfoMessage(Component aParent, String aMessage, String anInfoText) {
    JOptionPane.showMessageDialog(aParent, StringEscapeUtils.unescapeJava(aMessage), anInfoText,
            JOptionPane.INFORMATION_MESSAGE);
}

From source file:Main.java

/**
 * Shows an error dialog./*from ww w .j  ava  2s.c  om*/
 * 
 * <p>This can be called from a different thread from the event dispatch
 * thread, and it will be made thread-safe.</p>
 * 
 * @param component component
 * @param title title
 * @param message message
 */
public static void showError(final Component component, final String title, final String message) {
    if (!SwingUtilities.isEventDispatchThread()) {
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    showError(component, title, message);
                }
            });
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        }
        return;
    }

    String newMessage = message.replace(">", "&gt;").replace("<", "&lt;").replace("&", "&amp;");
    newMessage = "<html>" + newMessage;

    JOptionPane.showMessageDialog(component, newMessage, title, JOptionPane.ERROR_MESSAGE);
}

From source file:Models.UserModel.java

public Boolean SignUp(User user, String password) {
    try {//from  ww w.  j  a v a  2s .c o  m
        FileOutputStream file = new FileOutputStream("src/Data/users.dat");
        try (ObjectOutputStream oStream = new ObjectOutputStream(file)) {
            for (int i = 0; i < users.size(); ++i) {
                if (users.get(i).getEmail().equals(user.getEmail())) {
                    JOptionPane.showMessageDialog(null, "? c ng?i s dng email ny", "Li", 2);
                    return false;
                }
            }
            user.setAuth(HMAC_SHA256(user.getEmail(), password));
            users.add(user);
            oStream.writeObject(users);
            oStream.close();
            return true;

        }
    } catch (IOException e) {
        System.out.println(e.getMessage());
        JOptionPane.showMessageDialog(null, "Error write file", "ERROR", 2);
        return false;
    }
}

From source file:com.iucosoft.eavertizare.gui.models.FirmeListModel.java

public void refreshModel(Frame frame, String numeFirma) {
    super.clear();
    Firma firma = firmaDao.findByName(numeFirma);
    if (firma != null) {
        super.addElement("All firms");
        super.addElement(firma.getNumeFirma());
    } else {//from   ww  w.  j a  v a2  s . c om
        refreshModel();
        JOptionPane.showMessageDialog(frame, "Nu exista firma cu asa nume = " + numeFirma, "Error",
                JOptionPane.WARNING_MESSAGE);
    }

}

From source file:Main.java

/**
 * visualizzazione errori HTML - visualizza il messaggio da tabella errori.
 *
 * @param frame frame di provenienza (di solito e' <code>this</code>).
 * @param task task di provenienza dell'errore (di solito e'
 * <code>TASK_NAME</code>)./*from   w  w w .j ava2  s  .co m*/
 * @param error codice del messaggio
 * @param mess ulteriori dati da visualizzare
 */
public static void dispErrore(JFrame frame, String task, String error, String mess) {
    //
    JOptionPane.showMessageDialog(frame, componiStringaErrore(error, mess), ERR_TITLE,
            JOptionPane.ERROR_MESSAGE);
}

From source file:com.o2d.pkayjava.editor.CustomExceptionHandler.java

public static void showErrorDialog() {
    new Thread(new Runnable() {
        public void run() {
            EventQueue.invokeLater(new Runnable() {

                @Override/*from w  ww  . j  a v a 2 s  .  co m*/
                public void run() {
                    JOptionPane.showMessageDialog(null,
                            "Overlap2D just crashed, see stacktrace in overlog.txt file", "Error",
                            JOptionPane.ERROR_MESSAGE);
                }

            });
        }
    }).start();
}

From source file:br.usp.poli.lta.cereda.macro.util.DisplayUtils.java

/**
 * Exibe mensagem na tela.// w ww .j  av  a  2s.c  o m
 * @param title Ttulo da janela.
 * @param text Texto da mensagem.
 */
public static void showMessage(String title, String text) {
    JOptionPane.showMessageDialog(null, WordUtils.wrap(text, 70), title, JOptionPane.INFORMATION_MESSAGE);
}

From source file:Main.java

/**
 * visualizzazione errori HTML - visualizza il messaggio da tabella errori.
 *
 * @param iframe internal frmae di provenienza (di solito e'
 * <code>this</code>).//from   w ww  .  j a  va2  s  .  c  om
 * @param task task di provenienza dell'errore (di solito e'
 * <code>TASK_NAME</code>).
 * @param error codice del messaggio
 * @param mess ulteriori dati da visualizzare
 */
public static void dispInternalErrore(JInternalFrame iframe, String task, String error, String mess) {
    //
    JOptionPane.showMessageDialog(iframe, componiStringaErrore(error, mess), ERR_TITLE,
            JOptionPane.ERROR_MESSAGE);
}

From source file:com.ln.methods.Getcalendar.java

public static void Main() {
    //TODO store file locally and check if file changed == redownload
    try {//from  ww w  .  j  av a 2  s .c om

        //Get source
        // System.setProperty("http.agent", "lnrev2");
        URL calendar = new URL(Calendarurl);
        HttpURLConnection getsource = (HttpURLConnection) calendar.openConnection();
        InputStream in = new BufferedInputStream(getsource.getInputStream());
        //Write source
        Writer sw = new StringWriter();
        char[] b = new char[1024];
        Reader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
        int n;
        while ((n = reader.read(b)) != -1) {
            sw.write(b, 0, n);
        }
        //Source == String && Send source for parsing
        Parser.source = sw.toString();
        Betaparser.source = sw.toString();

        //String lol = sw.toString();
        //lol = StringUtils.substringBetween(lol, "<month year=\"2012\" num=\"2\">", "</month>");
        //Parser.parse();

        Betaparser.parse();

    } catch (MalformedURLException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, e.getStackTrace(), "Error", JOptionPane.WARNING_MESSAGE);
    } catch (IOException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, e.getStackTrace(), "Error", JOptionPane.WARNING_MESSAGE);
    }
}