/*
 This file is part of the software framework JStatCom, 
 a library for building applications for data based analysis.

 Copyright (C) 2000-2005  Markus Kraetzig

 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
 */

package com.jstatcom.io;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;

import com.jstatcom.component.ResultField;

/**
 * Frame that can be used as a log area for various kinds of
 * messages.
 *
 * @author Markus Kraetzig
 */
public final class LogFrame extends JFrame implements Logger {
	private JPanel ivjJFrameContentPane = null;
	private ResultField ivjResultField = null;

	/**
	 * Creates a LogFrame.
	 */
	public LogFrame() {
		super();
		initialize();
	}

	/**
	 * Appends text to the log that is made visible in
	 * a text area, where it can be cleared or saved.
	 *
	 * @param text String
	 */
	public void append(String text) {
		getResultField().append(text);
	}
	/**
	 * Shows this component.
	 * 
	 * @param show if true then show, otherwise hide
	 */
	public void showLog(boolean show) {
		setVisible(show);
	}
	/**
	 * Return the JFrameContentPane property value.
	 * @return javax.swing.JPanel
	 */
	/* WARNING: THIS METHOD WILL BE REGENERATED. */
	private javax.swing.JPanel getJFrameContentPane() {
		if (ivjJFrameContentPane == null) {
			try {
				ivjJFrameContentPane = new javax.swing.JPanel();
				ivjJFrameContentPane.setName("JFrameContentPane");
				ivjJFrameContentPane.setLayout(
					new javax.swing.BoxLayout(
						getJFrameContentPane(),
						javax.swing.BoxLayout.X_AXIS));
				getJFrameContentPane().add(
					getResultField(),
					getResultField().getName());
				// user code begin {1}
				// user code end
			} catch (Exception ivjExc) {
				// user code begin {2}
				// user code end
				handleException(ivjExc);
			}
		}
		return ivjJFrameContentPane;
	}

	/**
	 * Return the ResultField property value.
	 * @return ResultField
	 */
	/* WARNING: THIS METHOD WILL BE REGENERATED. */
	private com.jstatcom.component.ResultField getResultField() {
		if (ivjResultField == null) {
			try {
				ivjResultField = new com.jstatcom.component.ResultField();
				ivjResultField.setName("ResultField");
				// user code begin {1}
				// user code end
			} catch (Exception ivjExc) {
				// user code begin {2}
				// user code end
				handleException(ivjExc);
			}
		}
		return ivjResultField;
	}

	/**
	 * Called whenever the part throws an exception.
	 * @param exception Exception
	 */
	private void handleException(Exception exception) {

		/* Uncomment the following lines to print uncaught exceptions to stdout */
		System.out.println("--------- UNCAUGHT EXCEPTION ---------");
		exception.printStackTrace(System.out);
	}

	/**
	 * Initialize the class.
	 */
	/* WARNING: THIS METHOD WILL BE REGENERATED. */
	private void initialize() {
		try {
			// user code begin {1}

			// user code end
			setName("LogFrame");
			setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
			setSize(600, 400);
			setTitle("Logs");
			setContentPane(getJFrameContentPane());
		} catch (Exception ivjExc) {
			handleException(ivjExc);
		}

		URL url = getClass().getResource("/images/log.gif");
		if (url != null)
			setIconImage(new ImageIcon(url).getImage());

	}

	/**
	 * main entrypoint - starts the part when it is run as an application
	 * @param args String[]
	 */
	public static void main(String[] args) {
		try {
			LogFrame aLogFrame;
			aLogFrame = new LogFrame();
			aLogFrame.addWindowListener(new java.awt.event.WindowAdapter() {
				public void windowClosing(java.awt.event.WindowEvent e) {
					System.exit(0);
				};
			});
			aLogFrame.setVisible(true);
			java.awt.Insets insets = aLogFrame.getInsets();
			aLogFrame.setSize(
				aLogFrame.getWidth() + insets.left + insets.right,
				aLogFrame.getHeight() + insets.top + insets.bottom);
			aLogFrame.setVisible(true);
		} catch (Exception exception) {
			System.err.println(
				"Exception occurred in main() of javax.swing.JFrame");
			exception.printStackTrace(System.out);
		}
	}
}
 

Ads help maintain this website.