Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.awt.Frame;

import javax.swing.JDialog;

import javax.swing.JOptionPane;

public class Main {
    /**
     * Mostra uma caixa de menssagem para que seja ensirido um valor.
     * @param frame
     * @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;

    }
}