Java JOptionPane Error createAndShowErrorPanel(String title, Map messages)

Here you can find the source of createAndShowErrorPanel(String title, Map messages)

Description

create And Show Error Panel

License

Open Source License

Declaration

public static void createAndShowErrorPanel(String title, Map<String, String> messages) 

Method Source Code


//package com.java2s;
// This software is licensed under the GNU General Public License,

import java.awt.BorderLayout;

import java.util.Map;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextPane;
import javax.swing.ScrollPaneConstants;

public class Main {
    public static void createAndShowErrorPanel(String title, Map<String, String> messages) {
        JPanel jp = new JPanel(new BorderLayout(0, 0));
        jp.setPreferredSize(new java.awt.Dimension(640, 480));

        JTabbedPane tabs = null;//from w ww  . j  a  v a2s  . c  o m
        if (messages.size() > 1) {
            tabs = new JTabbedPane();
            jp.add(tabs);
        }

        for (String key : messages.keySet()) {
            JTextPane tp = new JTextPane();
            tp.setText(messages.get(key));

            JScrollPane jpMessage = new JScrollPane(tp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            if (messages.size() > 1) {
                tabs.add(key, jpMessage);
            } else {
                jp.add(jpMessage);
            }
        }

        JOptionPane.showMessageDialog(null, jp, title, JOptionPane.ERROR_MESSAGE);
    }
}

Related

  1. alertValidationError(final Component sourceComponent, final String message)
  2. askForAStringInArray(String question, String header, Object[] options, String errorMessage, String errorHeader)
  3. askForAStringInArrayReturning(String question, String header, T[] options, String errorMessage, String errorHeader)
  4. contChoose(final Component parent, final String title, final String message, final String noContMsg, boolean cont, boolean error)
  5. displayError(Component parent, String title, String message)
  6. displayError(String message)
  7. displayError(Throwable e)
  8. displayErrorMessage(Component component, Throwable t)