Module hw06

Class LoggerPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ILogEntryProcessor, IStringLogEntryProcessor

public class LoggerPanel extends JPanel implements IStringLogEntryProcessor
Simple display panel for logger output. This panel implements the IStringLogEntryProcessor and hence also ILogEntryProcessor, to facilitate its use by ILoggers. Note that this does not extend AStringLogEntryrocessor because of Java's multiple inheritance restrictions.
Author:
swong
See Also:
Serialized Form
  • Field Details

    • title

      private String title
      The title of the panel shown on its titled border
    • serialVersionUID

      private static final long serialVersionUID
      For serialization
      See Also:
      Constant Field Values
    • leFormatter

      private ILogEntryFormatter leFormatter
      The log entry formatter in use. This has to be explicitly implemented here because this JPanel cannot also extend AStringLogEntryProcessor. This could be done with as a decorated AStringLogEntryProcessor but was not deemed worth the trouble of its benefits.
    • spnDisplay

      private final JScrollPane spnDisplay
      Teh scrollbars around the text area
    • taDisplay

      private final JTextArea taDisplay
      The text display area
  • Constructor Details

    • LoggerPanel

      public LoggerPanel(String title)
      Create the panel with a given title
      Parameters:
      title - The border title used to identify this component on the GUI
    • LoggerPanel

      public LoggerPanel()
      Uses a default title for the panel's border.
  • Method Details

    • initGUI

      private void initGUI()
      Initialize the panel's GUI elements
    • accept

      public void accept(ILogEntry logEntry)
      Add a log entry to the display using the current log entry formatting function
      Specified by:
      accept in interface ILogEntryProcessor
      Parameters:
      logEntry - The log entry to append to the display
    • addMsg

      public void addMsg(String fullMsg)
      Add an already formatted message (linefeed NOT automatically added)
      Parameters:
      fullMsg - The message to display, already formatted as desired, including a trailing linefeed if needed.
    • setLogEntryFormatter

      public void setLogEntryFormatter(ILogEntryFormatter leFormatter)
      Description copied from interface: IStringLogEntryProcessor
      Set the log entry formatter in use to be the given formatter
      Specified by:
      setLogEntryFormatter in interface IStringLogEntryProcessor
      Parameters:
      leFormatter - The new log entry formatter to use
    • getLogEntryFormatter

      public ILogEntryFormatter getLogEntryFormatter()
      Description copied from interface: IStringLogEntryProcessor
      Get the current log entry formatter in use
      Specified by:
      getLogEntryFormatter in interface IStringLogEntryProcessor
      Returns:
      The log entry formatter in use