Example usage for javax.swing JOptionPane WARNING_MESSAGE

List of usage examples for javax.swing JOptionPane WARNING_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane WARNING_MESSAGE.

Prototype

int WARNING_MESSAGE

To view the source code for javax.swing JOptionPane WARNING_MESSAGE.

Click Source Link

Document

Used for warning messages.

Usage

From source file:Main.java

/**
 * Shows a warning message dialog./*from   w w  w  .j av  a2  s  . c om*/
 * 
 * @param c
 *            determines the Frame in which the dialog is displayed.
 * @param msg
 *            the message to display.
 */
public static void showWarningDialog(Component c, String msg) {
    JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(c), msg,
            UIManager.getString("OptionPane.warningDialogTitle"), JOptionPane.WARNING_MESSAGE);
}

From source file:Main.java

public static void warnUser(Component parent, String message) {
    JOptionPane.showMessageDialog(parent, message, "Warning", JOptionPane.WARNING_MESSAGE);
}

From source file:Main.java

/**
 * Show a warning window./*from  w  w  w .  j av a 2  s  . c o m*/
 * @param message   The message to show.
 * @param parent   Parent component of this dialog.
 */
public static void warning(String message, Component parent) {
    Toolkit.getDefaultToolkit().beep();
    JOptionPane.showMessageDialog(parent, message, "Warning", JOptionPane.WARNING_MESSAGE);
}

From source file:Main.java

public Main() {
    options.add(createOptionPane("Plain Message", JOptionPane.PLAIN_MESSAGE));
    options.add(createOptionPane("Error Message", JOptionPane.ERROR_MESSAGE));
    options.add(createOptionPane("Information Message", JOptionPane.INFORMATION_MESSAGE));
    options.add(createOptionPane("Warning Message", JOptionPane.WARNING_MESSAGE));
    options.add(createOptionPane("Want to do something?", JOptionPane.QUESTION_MESSAGE));
    items = new Object[] { "First", "Second", "Third" };
    JComboBox choiceCombo = new JComboBox(items);
    options.add(new JOptionPane(choiceCombo, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION),
            "Question Message");
    JFrame frame = new JFrame("JOptionPane'Options");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(options, BorderLayout.CENTER);
    frame.pack();//  ww w .ja va 2 s . c  o  m
    frame.setVisible(true);
}

From source file:Main.java

protected static void errorMessage(String errorMessage) {

    /**/*ww w . j a  v a  2  s .c  om*/
     * Display Jpanel Error messages any text Errors. Overloads
     * errorMessage(Exception exceptionMsg)
     */
    Object[] options = { "OK" };

    JOptionPane.showOptionDialog(null, errorMessage, messagerHeader, JOptionPane.DEFAULT_OPTION,
            JOptionPane.WARNING_MESSAGE, null, options, options[0]);

    // DatabaseManagerSwing.StatusMessage(READY_STATUS);
}

From source file:br.com.pontocontrol.controleponto.ControlePonto.java

public static void solicitarLogin() {
    String usuario;// w  ww.j a  v  a2  s  .  com
    do {
        usuario = JOptionPane.showInputDialog(null, "Informe seu usurio:", "Identificao",
                JOptionPane.INFORMATION_MESSAGE);
        if (StringUtils.isBlank(usuario)) {
            JOptionPane.showMessageDialog(null, "Informe um login de usurio.", "Validao falhou.",
                    JOptionPane.ERROR_MESSAGE);
        }
    } while (StringUtils.isBlank(usuario));
    switch (SessaoManager.getInstance().autenticar(usuario)) {
    case SessaoManager.LOGIN_STATUS.OK:

        break;
    case SessaoManager.LOGIN_STATUS.USUARIO_NAO_EXISTE:
        int opt = JOptionPane.showConfirmDialog(null,
                format("O usurio com o login informado \"%s\" no existe, deseja criar um novo usurio?",
                        usuario),
                "Usurio no encontrado.", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
        if (JOptionPane.YES_OPTION == opt) {
            ConfiguracoesUsuario configuracoesUsuario = new ConfiguracoesUsuario(usuario);
            SessaoManager.getInstance().criarUsuario(configuracoesUsuario);
            SessaoManager.getInstance().autenticar(usuario);
        }
        break;
    default:

        break;
    }
}

From source file:Main.java

/**
 * Asks the user for confirmation./*  w ww .j  a va 2  s  .c om*/
 * 
 * @param aWindow
 *          the parent window of the confirmation dialog;
 * @param aMessage
 *          the message to display in the confirmation dialog;
 * @param aTitle
 *          the title to display in the confirmation dialog.
 * @return <code>true</code> if the user acknowledged the confirmation,
 *         <code>false</code> otherwise.
 */
public static boolean askConfirmation(final Window aWindow, final String aMessage, final String aTitle) {
    return JOptionPane.showConfirmDialog(aWindow, aMessage, aTitle, JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION;
}

From source file:com.iucosoft.eavertizare.gui.models.FirmeListModel.java

public void refreshModel(Frame frame, String numeFirma) {
    super.clear();
    Firma firma = firmaDao.findByName(numeFirma);
    if (firma != null) {
        super.addElement("All firms");
        super.addElement(firma.getNumeFirma());
    } else {//from   w  w  w.  ja v a  2s  .c  o m
        refreshModel();
        JOptionPane.showMessageDialog(frame, "Nu exista firma cu asa nume = " + numeFirma, "Error",
                JOptionPane.WARNING_MESSAGE);
    }

}

From source file:com.ln.methods.Getcalendar.java

public static void Main() {
    //TODO store file locally and check if file changed == redownload
    try {/*from  w w  w .  ja  v a  2s.  c o m*/

        //Get source
        // System.setProperty("http.agent", "lnrev2");
        URL calendar = new URL(Calendarurl);
        HttpURLConnection getsource = (HttpURLConnection) calendar.openConnection();
        InputStream in = new BufferedInputStream(getsource.getInputStream());
        //Write source
        Writer sw = new StringWriter();
        char[] b = new char[1024];
        Reader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
        int n;
        while ((n = reader.read(b)) != -1) {
            sw.write(b, 0, n);
        }
        //Source == String && Send source for parsing
        Parser.source = sw.toString();
        Betaparser.source = sw.toString();

        //String lol = sw.toString();
        //lol = StringUtils.substringBetween(lol, "<month year=\"2012\" num=\"2\">", "</month>");
        //Parser.parse();

        Betaparser.parse();

    } catch (MalformedURLException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, e.getStackTrace(), "Error", JOptionPane.WARNING_MESSAGE);
    } catch (IOException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, e.getStackTrace(), "Error", JOptionPane.WARNING_MESSAGE);
    }
}

From source file:Main.java

public void actionPerformed(ActionEvent e) {
    String menuText = ((JMenuItem) e.getSource()).getText();
    int messageType = JOptionPane.INFORMATION_MESSAGE;
    if (menuText.equals("Information")) {
        messageType = JOptionPane.INFORMATION_MESSAGE;
    } else if (menuText.equals("Warning")) {
        messageType = JOptionPane.WARNING_MESSAGE;
    } else if (menuText.equals("Error")) {
        messageType = JOptionPane.ERROR_MESSAGE;
    } else if (menuText.equals("Plain")) {
        messageType = JOptionPane.PLAIN_MESSAGE;
    }//w w  w  . j  a va  2 s .  c o  m

    JOptionPane.showMessageDialog(myFrame, "This is message dialog box of type: " + menuText,
            menuText + " Message", messageType);
}