ITeye博客

TextAreaConsole

mmdev · 2011-12-08 10:08 · Markdown

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的使用可以参照《文件删除器(二)》

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。