TextAreaConsole
TextAreaConsole是JTextArea作为输出,实现了Console(com.teleca.robin.lib.face)的类.
源码文件TextAreaConsole.java如下:
package com.teleca.robin.lib.util;
import javax.swing.JTextArea;
import com.teleca.robin.lib.face.Console;
public classTextAreaConsoleimplements Console{
StringBuffer strBuffer=new StringBuffer();
private javax.swing.JTextArea textArea;
publicTextAreaConsole(JTextArea textArea)
{
this.textArea=textArea;
}
public voidappend(String str) {
// TODO Auto-generated method stub
strBuffer.append(str);
}
public voidclear(){
// TODO Auto-generated method stub
textArea.setText("");
textArea.repaint();
}
public voidflush() {
// TODO Auto-generated method stub
textArea.append(strBuffer.toString());
textArea.repaint();
strBuffer.delete(0, strBuffer.length());
}
public final voidprint(String str) {
// TODO Auto-generated method stub
textArea.append(str);
textArea.repaint();
}
public voidprintln(String str) {
// TODO Auto-generated method stub
textArea.append(str);
textArea.append("\n");
int len=textArea.getText().length();
textArea.setCaretPosition(len);
textArea.repaint();
}
}
注1:关于Console(com.teleca.robin.lib.face)的更多内容请参照《Console》。
注2:关于TextAreaConsole的使用可以参照《文件删除器(二)》