Java JOptionPane Message show(String title, int type, Object message, Object[] options, Object initialOption)

Here you can find the source of show(String title, int type, Object message, Object[] options, Object initialOption)

Description

Helper method for constructing an always-on-top modal dialog.

License

Open Source License

Declaration

public static Object show(String title, int type, Object message, Object[] options, Object initialOption) 

Method Source Code

//package com.java2s;
/**//from w w  w  .  ja  v  a2s.co  m
 * ============================================================================================
 * Menthor Editor -- Copyright (c) 2015 
 *
 * This file is part of Menthor Editor. Menthor Editor is based on TinyUML and as so it is 
 * distributed under the same license terms.
 *
 * Menthor Editor is free software; you can redistribute it and/or modify it under the terms 
 * of the GNU General Public License as published by the Free Software Foundation; either 
 * version 2 of the License, or (at your option) any later version.
 *
 * Menthor Editor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with Menthor Editor; 
 * if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 
 * MA  02110-1301  USA
 * ============================================================================================
 */

import javax.swing.JDialog;

import javax.swing.JOptionPane;

public class Main {
    /** Helper method for constructing an always-on-top modal dialog. */
    public static Object show(String title, int type, Object message, Object[] options, Object initialOption) {
        if (options == null) {
            options = new Object[] { "Ok" };
            initialOption = "Ok";
        }
        JOptionPane p = new JOptionPane(message, type, JOptionPane.DEFAULT_OPTION, null, options, initialOption);
        p.setInitialValue(initialOption);
        JDialog d = p.createDialog(null, title);
        p.selectInitialValue();
        d.setAlwaysOnTop(true);
        d.setVisible(true);
        d.dispose();
        return p.getValue();
    }
}

Related

  1. queryBoolean(String message)
  2. queryDouble(String message, double initialValue)
  3. queryInt(String message, int initialValue)
  4. requestPassword(String titulo, String msg)
  5. select(String[] selList, String msg)
  6. showActionFailedWithExceptionMessage(final Component parent, final Exception ex)
  7. showAlert(String message)
  8. showException(Component c, String message, Throwable t)
  9. showException(String message, Exception ex)