UNB/ CS/ David Bremner/ teaching/ java/ TextFrame.java
import javax.swing.JFrame;
import java.io.FileReader;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import java.io.FileNotFoundException;
import java.io.BufferedReader;
import java.io.IOException;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.GraphicsEnvironment;
import java.awt.Font;
import java.io.InputStreamReader;
import java.io.FileInputStream;
public class TextFrame extends JFrame{
    
    public TextFrame(String fileName) throws FileNotFoundException, IOException{
        InputStreamReader charFile=new InputStreamReader(new FileInputStream(fileName),"UTF-8");
        BufferedReader inFile=new BufferedReader(charFile);
        
        System.out.println(charFile.getEncoding());
        
        JTextArea  display=new JTextArea(24,80);
        //      display.setFont(Font.decode("Lucida Sans Regular").deriveFont((float)18));
        System.out.println(display.getFont().toString()+" "+display.getFont().getNumGlyphs());
        
        getContentPane().add(new JScrollPane(display));
        

        String inLine=inFile.readLine();
        while(inLine != null){
            display.append(inLine+"\n");
            inLine=inFile.readLine();                      
        }
        pack();
        addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) { System.exit(0); }
            });


        setVisible(true);
    }


    public static void main(String [] args) throws FileNotFoundException, IOException{

        TextFrame tf=new TextFrame("utf8.dat");
        
    }
}
//