/*
 * OutputStreamPanel.java
 *
 * Created on Ketvirtadienis, 2007, Sausio 25, 17.17
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package Main.panels;

import Main.util.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;


public class OutputStreamPanel extends JPanel implements Log
{
	private final String CLEAR= "Clear";
	JTextArea mText;
	JButton mClearButton;
	
	public OutputStreamPanel()
	{
		setLayout(new GridBagLayout());
		GridBagConstraints gbc;
		
		mText= new JTextArea();
		gbc= new GridBagConstraints();
		gbc.fill= GridBagConstraints.BOTH;
		gbc.anchor= GridBagConstraints.NORTH;
		gbc.gridx= 1;
		gbc.gridy= 1;
		gbc.gridwidth= 3;
		gbc.gridheight= 3;
		gbc.weighty= 1;
		gbc.weightx=1;
		gbc.insets = new Insets(5,5,5,5);
		
		JScrollPane scrol= new JScrollPane(mText);
		
		((GridBagLayout)getLayout()).setConstraints(scrol,gbc);
		add(scrol);
		
		mClearButton= new JButton(CLEAR);
		gbc= new GridBagConstraints();
		gbc.fill= GridBagConstraints.NONE;
		gbc.gridx= 3;
		gbc.gridy= 4;
		gbc.insets = new Insets(5,5,5,5);
		((GridBagLayout)getLayout()).setConstraints(mClearButton,gbc);
		add(mClearButton);
		
		mClearButton.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				mText.setText("");
			}
		}
		);
	}
		
		public void log(String s)
		{
			mText.append(s);
		}
		
		public void logn(String s)
		{
			log(s+"\n");
		}
		
		public void logn()
		{
			log("\n");
		}
	
}

