//******************************************************************//
//**                                                              **//
//**   file_Name : f_view.java                                    **//
//**   Version   : 1.0                                            **//
//**   作者      : かいせき屋                                      **//
//**               www.asahi-net.or.jp/~yx2m-sn                   **//
//**               yx2m-sn@asahi-net.or.jp             **//
//**                                                              **//
//** -------------------------------------------------------------**//
//**                                                              **//
//**   機能       : ソースファイルなどのテキストファイルを表示        **//
//**             : するツール                                     **//
//**                                                              **//
//**   Ver 1.00  1997/08/27                                       **//
//**   Ver 1.50  2001/05/10 JAVA2対応 日本語表示対応              **//
//**                                                              **//
//******************************************************************//

import java.applet.Applet;
import java.awt.*;
import java.util.*;
import java.net.*;
import java.io.*;


public class f_view extends java.applet.Applet {
		Image buf;                               
		Graphics gBuf;
		Font textFont;
		String fontname="FixedSys";

		TextArea tr;
		String str="";
		InputStream is;
        BufferedReader ds;
		BufferedInputStream bs;
		
	public void init() {
		Dimension d = getSize();
		buf  = createImage(d.width,d.height);  
		gBuf = buf.getGraphics(); 
		str=get_file();
		setBackground(Color.lightGray);
		setLayout(null);
		
		textFont = new Font( fontname, Font.PLAIN,13);
		tr = new TextArea(20,80);
		add(tr);
		tr.setBounds(0,0,d.width,d.height);
		tr.setFont(textFont);
		tr.setText(str);
	}

    public void destroy() { gBuf.dispose(); } 

    public void update(Graphics g) { paint(g); }   
    
    public void paint(Graphics g) {
	  //g.setFont( textFont );
      g.drawImage(buf,0,0,this);          
    }

  public String get_file(){
		String str="",filename,buf="";
		filename = getParameter("filename");

		if(filename != null){
		  try {
			is = new URL(getDocumentBase(),filename).openStream();
			ds = new BufferedReader(new InputStreamReader(is));
		  }  catch( MalformedURLException e ) {}
			 catch( IOException e1){}

		  try {
			while( (buf = ds.readLine()) != null){
				str = str + buf +'\n';
				buf = "";
			}
		  } catch( IOException e2 ){}

		  try {
			is.close();
		  } catch( IOException e4 ){}
		}
		return str;
  }

}