ptwuzhsh
发贴: 3
积分: 0
|
于 2007-11-03 21:21
JTextArea text = new JTextArea(); OutputStream textAreaStream = new OutputStream() { public void write(int b) throws IOException { text.append(String.valueOf((char) b)); }
public void write(byte b[]) throws IOException { text.append(new String); }
public void write(byte b[], int off, int len) throws IOException { text.append(new String(b, off, len)); } }; PrintStream myOut = new PrintStream(textAreaStream); 这是一段将system.out.println的输出转到控件text的代码,但是 当我按下按钮 JButton jb = new JButton(); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (int tmp=0;tmp <10000;tmp++){ System.out.println( "(*^__^*) 嘻嘻…… "+tmp); } } }); 就能感觉到不会想java IDE里面的控制台那样逐行输出,而是停顿一会儿之后一并输出 我想达到像jbuilder或eclipse的控制台那样逐行输出,如何能做到呢?
|