Class MessageConsole

java.lang.Object
be.gaudry.swing.utils.console.MessageConsole

public class MessageConsole extends Object
Creates a simple console to display text messages. Has its messages displayed in a different color. Messages can either be appended to the console or inserted as the first line of the console You can limit the number of lines to hold in the Document. found on http://www.tips4java.wordpress.com
Since:
1.0 Nov 25, 2009, 1.0
Version:
%I%, %G%
Author:
Steph GAUDRY
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) class 
    Class to intercept output from a PrintStream and add it to a Document.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) PrintStream
     
    (package private) PrintStream
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    MessageConsole​(JTextComponent textComponent)
     
    MessageConsole​(JTextComponent textComponent, boolean isAppend)
    Use the text component specified as a simply console to display text messages.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes the text
    void
    Redirect the output from the standard error to the console using the default text color and null PrintStream
    void
    redirectErr​(Color textColor, PrintStream printStream)
    Redirect the output from the standard error to the console using the specified color and PrintStream.
    void
    Redirect the output from the standard output to the console using the default text color and null PrintStream
    void
    redirectOut​(Color textColor, PrintStream printStream)
    Redirect the output from the standard output to the console using the specified color and PrintStream.
    void
    Reset the System.out and System.err outputs to default
    void
    setMessageLines​(int lines)
    To prevent memory from being used up you can control the number of lines to display in the console This number can be dynamically changed, but the console will only be updated the next time the Document is updated.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • MessageConsole

      public MessageConsole(JTextComponent textComponent)
    • MessageConsole

      public MessageConsole(JTextComponent textComponent, boolean isAppend)
      Use the text component specified as a simply console to display text messages. The messages can either be appended to the end of the console or inserted as the first line of the console.
  • Method Details

    • resetOutput

      public void resetOutput()
      Reset the System.out and System.err outputs to default
    • clean

      public void clean()
      Removes the text
    • redirectOut

      public void redirectOut()
      Redirect the output from the standard output to the console using the default text color and null PrintStream
    • redirectOut

      public void redirectOut(Color textColor, PrintStream printStream)
      Redirect the output from the standard output to the console using the specified color and PrintStream. When a PrintStream is specified the message will be added to the Document before it is also written to the PrintStream.
    • redirectErr

      public void redirectErr()
      Redirect the output from the standard error to the console using the default text color and null PrintStream
    • redirectErr

      public void redirectErr(Color textColor, PrintStream printStream)
      Redirect the output from the standard error to the console using the specified color and PrintStream. When a PrintStream is specified the message will be added to the Document before it is also written to the PrintStream.
    • setMessageLines

      public void setMessageLines(int lines)
      To prevent memory from being used up you can control the number of lines to display in the console This number can be dynamically changed, but the console will only be updated the next time the Document is updated.