FileDocCategorySizeDatePackage
StdErrOutWindows.javaAPI DocExample2230Mon Jan 09 11:02:02 GMT 2006None

StdErrOutWindows

public class StdErrOutWindows extends Object

Fields Summary
JTextArea
outArea
JTextArea
errArea
Constructors Summary
public StdErrOutWindows()

        // out
        outArea = new JTextArea (20, 50);
        JScrollPane pain =
            new JScrollPane (outArea,
                             ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                             ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        JFrame outFrame = new JFrame ("out");
        outFrame.getContentPane().add (pain);
        outFrame.pack();
        outFrame.setVisible(true);
        // err
        errArea = new JTextArea (20, 50);
        pain =
            new JScrollPane (errArea,
                             ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                             ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        JFrame errFrame = new JFrame ("err");
        errFrame.getContentPane().add (pain);
        errFrame.pack();
        errFrame.setLocation (errFrame.getLocation().x + 20,
                              errFrame.getLocation().y + 20);
        errFrame.setVisible (true);
        // set up streams
        System.setOut (new PrintStream (new JTextAreaOutputStream (outArea)));
        System.setErr (new PrintStream (new JTextAreaOutputStream (errArea)));
    
Methods Summary
public static voidmain(java.lang.String[] args)

        new StdErrOutWindows();
        // test
        System.out.println ("test to out");
        System.out.println ("another test to out");
        try {
            throw new Exception ("Test exception");
        } catch (Exception e) {
            e.printStackTrace();
        }