1

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.setErr( 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 );
    }
}
}
Community
  • 1
  • 1
JDN
  • 509
  • 3
  • 8
  • 14

1 Answers1

0

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.

Ryan Stewart
  • 126,015
  • 21
  • 180
  • 199