Example usage for javax.swing JDialog setFocusableWindowState

List of usage examples for javax.swing JDialog setFocusableWindowState

Introduction

In this page you can find the example usage for javax.swing JDialog setFocusableWindowState.

Prototype

public void setFocusableWindowState(boolean focusableWindowState) 

Source Link

Document

Sets whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow .

Usage

From source file:Main.java

/**
 * Mostra uma caixa de menssagem para que seja ensirido um valor.
 * @param frame/*from   w  w w.j a  va2s.  c  om*/
 * @param texto
 * @param title
 * @param valorInicial
 * @param type
 * @return
 * @author Thiago Benega
 * @since 13/04/2009
 */
public static String showTextboxDialog(javax.swing.JFrame frame, String texto, String title,
        String valorInicial, int type) {
    Object txt = null;
    JDialog jDialog = new JDialog();
    jDialog.setTitle(title);
    jDialog.setFocusableWindowState(true);

    if (frame != null) {
        frame.setExtendedState(Frame.ICONIFIED);
        frame.pack();
        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    }

    switch (type) {
    case JOptionPane.OK_CANCEL_OPTION:
        txt = JOptionPane.showInputDialog(jDialog, texto, title, type, null, null, valorInicial);//.toString();
        break;
    case JOptionPane.YES_NO_OPTION:
        txt = JOptionPane.showConfirmDialog(jDialog, texto, title, type, JOptionPane.INFORMATION_MESSAGE);
        break;
    default:
        JOptionPane.showMessageDialog(jDialog, texto, title, type);
        break;
    }

    jDialog = null;
    return txt != null ? txt.toString() : null;

}