Java JOptionPane Message msg(int options, String title, String msg, String item, String sep)

Here you can find the source of msg(int options, String title, String msg, String item, String sep)

Description

Show a message with options to choose from

Wrapper for JOptionPane with I18N support

License

Open Source License

Parameter

Parameter Description
options the options to be shown in the dialog
title the title to be shown in the dialog
msg the message to be shown in the dialog
item a variable part to be shown before msg
sep a separator for msg and item (return or blank etc.)

Return

true, if YES was chosen, false if not

Declaration

public static boolean msg(int options, String title, String msg, String item, String sep) 

Method Source Code

//package com.java2s;
/*//from   w  w  w  . j  a  va 2 s .  com
 * This file is part of the Scriba source distribution. This is free, open-source 
 * software. For full licensing information, please see the LicensingInformation file
 * at the root level of the distribution.
 *
 * Copyright (c) 2006-2007 Kobrix Software, Inc.
 */

import javax.swing.JOptionPane;

public class Main {
    /**
     * Show a message with options to choose from
     * 
     * <p>
     * Wrapper for JOptionPane with I18N support
     * </p>
     * 
     * @param options the options to be shown in the dialog
     * @param title the title to be shown in the dialog
     * @param msg the message to be shown in the dialog
     * @param item a variable part to be shown before msg
     * @param sep a separator for msg and item (return or blank etc.)
     * 
     * @return true, if YES was chosen, false if not
     */
    public static boolean msg(int options, String title, String msg, String item, String sep) {
        return (msgChoice(options, title, msg, item, sep) == JOptionPane.YES_OPTION);
    }

    /**
     * Show a message with options to choose from
     * 
     * <p>
     * Wrapper for JOptionPane with I18N support
     * </p>
     * 
     * @param options the options to be shown in the dialog
     * @param title the title to be shown in the dialog
     * @param msg the message to be shown in the dialog
     * @param item a variable part to be shown before msg
     * @param sep a separator for msg and item (return or blank etc.)
     * 
     * @return the choice
     */
    public static int msgChoice(int options, String title, String msg, String item, String sep) {
        String message = item + sep + msg;
        return JOptionPane.showConfirmDialog(null, message, title, options, JOptionPane.QUESTION_MESSAGE);
    }
}

Related

  1. log(String msg)
  2. message(Component comp, String title, String message)
  3. message(String s)
  4. message(String s)
  5. messageBox(String s)
  6. Msg(JComponent parent, Object message)
  7. msg(String msg)
  8. msg(String s)
  9. msgbox(Object message)