开发者

How do I get this to run. I keep on getting a cannot find symbol

开发者 https://www.devze.com 2023-04-09 17:05 出处:网络
I saw this code on this stackoverflow question at Create Java console inside a GUI panel Whenever I compile the code though I get an error saying it can\'t find the symbol TextAreaOutputStream. I re

I saw this code on this stackoverflow question at Create Java console inside a GUI panel

Whenever I compile the code though I get an error saying it can't find the symbol TextAreaOutputStream. I really want to have this work. I would really appreciate an explanation for why I can't compile this.

 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;
 import java.io.*;

public class GUI{
public static void main( String [] args ) throws InterruptedException  {
    JFrame frame = new JFrame();
    frame.add( new JLabel(" Outout" ), BorderLayout.NORTH );

    JTextArea ta = new JTextArea();
    TextAreaOutputStream taos = new TextAreaOutputStream( ta, 60 );
    PrintStream ps = new PrintStream( taos );
    System.setOut( ps );
    System.set开发者_JAVA技巧Err( ps );


    frame.add( new JScrollPane( ta )  );

    frame.pack();
    frame.setVisible( true );

    for( int i = 0 ; i < 100 ; i++ ) {
        System.out.println( i );
        Thread.sleep( 500 );
    }
}
}


TextAreaOutputStream isn't a class included in the standard library. The code for it is in that other SO post you referenced. To use it, you'll have to copy/paste that code and compile it along with your class. You might be better off looking around for an existing library that does what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消