Java JFrame getUserInput(JFrame _frame, String arg1, String arg2, Object arg3)

Here you can find the source of getUserInput(JFrame _frame, String arg1, String arg2, Object arg3)

Description

get User Input

License

Open Source License

Declaration

public static String getUserInput(JFrame _frame, String arg1, String arg2, Object arg3) 

Method Source Code


//package com.java2s;
/*// ww  w .  ja  v a2  s  .  c  o  m
 * @(#)CommonGui
 *
 * Copyright (c) 2004-2008 by dvb.matt, All Rights Reserved. 
 * 
 * This file is part of ProjectX, a free Java based demux utility.
 * By the authors, ProjectX is intended for educational purposes only, 
 * as a non-commercial test project.
 * 
 *
 * This program 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.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

import javax.swing.JOptionPane;
import javax.swing.JFrame;

public class Main {
    private static JFrame frame = null;
    private static Object suggestion = null;

    /**
     *
     */
    public static String getUserInput(String arg1) {
        return getUserInput(arg1, null);
    }

    /**
     *
     */
    public static String getUserInput(String arg1, String arg2) {
        Object obj = getUserInput(arg1, arg2, suggestion);

        if (obj != null) {
            suggestion = obj;
            return obj.toString();
        }

        return null;
    }

    /**
     * user dialog field filled with suggestion
     * by 'mcr42' 2005/06/16
     */
    public static String getUserInput(String arg1, String arg2, Object arg3) {
        return getUserInput(null, arg1, arg2, arg3);
    }

    /**
     *
     */
    public static String getUserInput(JFrame _frame, String arg1, String arg2, Object arg3) {
        if (_frame == null)
            _frame = frame;

        Object obj = JOptionPane.showInputDialog(_frame, arg1, arg2, JOptionPane.QUESTION_MESSAGE, null, null,
                arg3);

        if (obj != null)
            return obj.toString();

        return null;
    }
}

Related

  1. getPersistentExtendedStateMask(JFrame frame)
  2. getRootJFrame(Component c)
  3. getRootJFrame(Component component)
  4. getTheJFrame(String title, int width, int height, int x, int y)
  5. getTopJFrame(Container c)
  6. getViewMenu(JFrame mainFrame)
  7. giveFrameHalfScreen(final JFrame frame)
  8. igualarFormularios(JFrame destino, JFrame origen)
  9. inputFiles(JFrame argParent)