Java JOptionPane Warning warning(String Msg)

Here you can find the source of warning(String Msg)

Description

Short version of warning method - uses default frame, and has the title 'Warning'.

License

Open Source License

Parameter

Parameter Description
Msg the warning message to display.

Declaration

public static boolean warning(String Msg) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Component;

import java.awt.Frame;

import javax.swing.JOptionPane;

public class Main {
    private static Frame displayFrame = null;

    /**/*from  w  w w.  ja v  a2s.c  om*/
    *    utility ftn; prints warning dialog message to the user,
    *    *without* echoing to the log ftn.  Basically wrapper to JOptionPane
    *
    *    @param caller the GUI component calling (required for dialog box drawing)
    *    @param Msg a short one line message to display to the user
    *    @return returns false for easy chaining.
    */

    public static boolean warning(Component caller, String Msg, String Title) {
        JOptionPane.showMessageDialog(caller, Msg, Title, JOptionPane.WARNING_MESSAGE);
        return false; // for chaining
    }

    /**
     *    Short version of warning method - uses default frame, and has the
     *    title 'Warning'.
     *    @param Msg the warning message to display.
     */
    public static boolean warning(String Msg) {
        if (displayFrame == null) // no default display registered
        {
            System.out.println("warning display not initialised! (error was: " + Msg + ")");
            return false;
        }
        return warning(displayFrame, Msg, "Warning");
    }
}

Related

  1. warn(Component parent, String message)
  2. warn(Component parent, String message)
  3. warn(String message)
  4. warning(String message, Component parent)
  5. warning(String msg)
  6. warning(String title, Object message, JComponent parent)
  7. warningMessage(Component component, String title, String message)
  8. warningMessage(final String title, final String content)
  9. warnMsg(final String msg)