文件名称:java抽象类
文件大小:43B
文件格式:JAVA
更新时间:2014-12-20 12:16:42
抽象类
抽象类import java.awt.*; import javax.swing.*; import java.io.*; class JTextAreaTest extends JFrame{ JTextArea t; JTextAreaTest(){ super("JTextAreaTest&JScrollpane Test"); this.setDefaultCloseOperation(this.EXIT_ON_CLOSE); Container c = this.getContentPane(); c.setLayout(new FlowLayout()); init(); c.add(new JLabel("My Java Reader")); c.add(new JScrollPane(t)); this.setBounds(300,300,500,300); this.setVisible(true); } void init(){ t = new JTextArea(10,35); t.setText(getFileText()); t.setFont(new Font("",Font.PLAIN,16)); t.setLineWrap(true); } String getFileText(){ byte[] b = null; try{ FileInputStream in = new FileInputStream("read.txt"); int l = in.available(); b = new byte[l]; in.read(b); in.close(); } catch(IOException e){} return new String(b); } public static void main(String[] args){ new JTextAreaTest(); } }