Java JOptionPane Warning showWarning(final String message)

Here you can find the source of showWarning(final String message)

Description

show Warning

License

LGPL

Declaration

private static void showWarning(final String message) 

Method Source Code


//package com.java2s;
/*/*from  www.ja v a  2s  .  c  o  m*/
 * IconUtils.java
 *
 * Copyright (c) 2009 JAM Development Team
 *
 * This package is distributed under the Lesser Gnu Public Licence (LGPL)
 *
 */

import javax.swing.*;

import java.awt.*;

import java.lang.reflect.InvocationTargetException;

public class Main {
    private static void showWarning(final String message) {

        if (EventQueue.isDispatchThread()) {
            JOptionPane.showMessageDialog(null, message, "Warning", JOptionPane.WARNING_MESSAGE);
        } else {
            // must show message dialog in the event dispatch thread, otherwise can crash
            try {
                EventQueue.invokeAndWait(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(null, message, "Warning", JOptionPane.WARNING_MESSAGE);

                    }
                });
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        }

    }
}

Related

  1. popupPrompt(String title, String message, @SuppressWarnings("SameParameterValue") String[] choices, String defaultOption)
  2. showPrettyWarningPromptPane(Component caller, String msg)
  3. showWarning(Component owner, String msg)
  4. showWarning(Component parent, String title, String message)
  5. showWarning(final Component rootComponent, final String message, final String title)
  6. showWarning(String message)
  7. showWarning(String message)
  8. showWarningBox(Component pParent, String pMessage, String pTitle)
  9. showWarningConfirmBox(Component pParent, String pMessage, String pTitle, String pLeftOption, String pRightOption)