/* dIntProg Browser. A webbrowser written in Java.
 * Copyright (C) 2001 Martin Geisler <gimpster@gimpster.com>
 *  
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 * 
 * This program 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
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the
 * 
 * Free Software Foundation, Inc.,
 * 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

import java.awt.Font;
import java.net.URL;

/** This class is used to generage error-pages. */
public class ErrorPage extends VerticalBoxStack {

    /** Generates a page with an error-message.
     *  @param m the errormessage.
     *  @param url the url of the current page. A link is made to the
     *  page, so that people can try again if they want. */
    public ErrorPage(String m, URL url) {
        TextFragment heading, text, reason, help, again;

        heading = new TextFragment("The page couldn't be displayed" ,
                                   new Font(null, Font.PLAIN, 24), null);
        text = new TextFragment("The reason: ",
                                new Font(null, Font.PLAIN, 14), null);
        reason = new TextFragment(m + " ",
                                  new Font(null, Font.ITALIC, 14), null);
        
        help = new TextFragment("You should check your spelling if you " +
                                "typed in the URL yourself, and come " +
                                "back later if the problem persists.",
                                new Font(null, Font.PLAIN, 14), null);
        
        again = new TextFragment("Click here to try again.",
                                 new Font(null, Font.PLAIN, 14),
                                 url);
        
        Paragraph par1 = new Paragraph();
        par1.insert(heading);

        Paragraph par2 = new Paragraph();
        par2.insert(text);

        Paragraph par3 = new Paragraph();
        par3.insert(reason);

        BlockQuote block = new BlockQuote();
        block.insert(par3);

        Paragraph par4 = new Paragraph();
        par4.insert(help);
        par4.insert(again);

        insert(par1);
        insert(par2);
        insert(block);
        insert(new HorizontalRule());
        insert(par4);
    }

}