Java JFrame dispErrore(JFrame frame, String task, String mess)

Here you can find the source of dispErrore(JFrame frame, String task, String mess)

Description

visualizzazione errori HTML

License

Open Source License

Parameter

Parameter Description
frame frame di provenienza (di solito e' <code>this</code>).
task task di provenienza dell'errore (di solito e' <code>TASK_NAME</code>).
mess messaggio da visualizzare

Declaration

public static void dispErrore(JFrame frame, String task, String mess) 

Method Source Code

//package com.java2s;
/*/*from   w  w  w . ja va2s  .c  om*/
 The GUFF - The GNU Ultimate Framework Facility
 Copyright (C) Simeosoft di Carlo Simeone
       
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.
    
 This library 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
 Lesser General Public License for more details.
    
 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   
 */

import javax.swing.*;

public class Main {
    final static String ERR_TITLE = "Errore!";
    final static String MSG_UNKNOWN = "** messaggio sconosciuto **";
    final static String[][] taberr = { { "ERR-DB-01", "Errore accesso al database!" },
            { "ERR-DB-02", "Errore istanza tabella database!" },
            { "ERR-DB-03", "Errore esecuzione query primaria!" }, { "ERR-DB-04", "Errore esecuzione query!" }, };

    /**
     * visualizzazione errori HTML
     *
     * @param frame frame di provenienza (di solito e' <code>this</code>).
     * @param task task di provenienza dell'errore (di solito e'
     * <code>TASK_NAME</code>).
     * @param mess messaggio da visualizzare
     */
    public static void dispErrore(JFrame frame, String task, String mess) {
        //
        JOptionPane.showMessageDialog(frame, formattaHTML(mess), ERR_TITLE, JOptionPane.ERROR_MESSAGE);
    }

    /**
     * visualizzazione errori HTML - visualizza il messaggio da tabella errori.
     *
     * @param frame frame di provenienza (di solito e' <code>this</code>).
     * @param task task di provenienza dell'errore (di solito e'
     * <code>TASK_NAME</code>).
     * @param error codice del messaggio
     * @param mess ulteriori dati da visualizzare
     */
    public static void dispErrore(JFrame frame, String task, String error, String mess) {
        //
        JOptionPane.showMessageDialog(frame, componiStringaErrore(error, mess), ERR_TITLE,
                JOptionPane.ERROR_MESSAGE);
    }

    /**
     * funzioni di utilita'
     */
    private static String formattaHTML(String pStr) {
        return ("<HTML><BODY><P>" + pStr + "</P></BODY></HTML>");
    }

    private static String componiStringaErrore(String pError, String pMessaggio) {
        String deserr = MSG_UNKNOWN;
        for (int i = 0; i < taberr.length; i++) {
            if (taberr[i][0].equalsIgnoreCase(pError)) {
                deserr = taberr[i][1];
            }
        }

        return formattaHTML("<p align=center><font color='red'>" + ERR_TITLE + "</font></p>" + "<font color='blue'>"
                + pError + "</font><br>" + "<font color='blue'>" + deserr + "</font><br>" + "<font color='red'>"
                + pMessaggio + "</font><br>" + "<font color='black'><i>contatto:</i></font>&nbsp;"
                + "<font color='black'>assist_gest@itelnet.it</font><br>");
    }
}

Related

  1. createPackedJFrame( java.awt.Component content, String title, int closeOperation)
  2. decorateFrame(JFrame frame, JMenuBar menuBar)
  3. deleteFile(String filepath, JFrame parent)
  4. dialogYesNo(JFrame frame, String title, String message, Object[] options)
  5. dispAlert(JFrame pFrame, String pTask, String pMessaggio)
  6. display(JFrame parent, JInternalFrame dialog)
  7. displayConfirmationMessage(JFrame parent, String message, String title)
  8. displayError(Exception e, JFrame jFrame)
  9. displayWindow(final JFrame window)