Class UiLog

All Implemented Interfaces:
LogInterface, AutoCloseable

public class UiLog extends TextLog implements LogInterface
This is an implementation of LogInterface that uses a javax.swing.JLabel field to display messages. it also does modal messages and will log them if asked.

See LogInterface

Copyright 2003-2026 ATB Consultancy Services Ltd (formerly Orinda Software Ltd, Dublin, Ireland)

Version:
7
Author:
[email protected]
  • Constructor Details

    • UiLog

      public UiLog(String theDirectoryName, String thePrefix, JLabel theLabel, JFrame theFrame)
      Create an instance of UiLog.
      Parameters:
      theDirectoryName - A string containing a logging directory path name. If the directory doesn't exist we'll attempt to create it. If we can't create it then we lose the ability to log messages.
      thePrefix - A string containing a the prefix used to name the log files.
      theLabel - A JLabel. We assume that it's a suitable location for a message, such as a line at the bottom of the screen.
      theFrame - The current application frame. We need to know this in order to refresh the graphics context so that messages will become visible to the end user.
  • Method Details

    • mapMessageType

      public static int mapMessageType(String messageType)
      Map LogInterface message types to JOptionPane message types
      Parameters:
      messageType - A valid LogInterface messageType, such as LogInterface.DEBUG, LogInterface.INFO, LogInterface.WARN, LogInterface.ERROR, LogInterface.SYSERR
      Returns:
      A JOptionPane message type.
      See Also:
    • useJTextArea

      public void useJTextArea(boolean useArea)
      Prevent or allow messages from being written to the text area as well as the log file.
    • clearJTextArea

      public void clearJTextArea()
      Clear the text area
    • addJTextArea

      public void addJTextArea(JTextArea newTextArea, int lines)
      Set a new Text Area
    • writeMessage

      protected void writeMessage(String messageType, String messageText, boolean isModal, boolean isLogged)
      Format a message and write it to the JLabel theLabel.
      Overrides:
      writeMessage in class TextLog
      Parameters:
      messageType - should be one of the constants DEBUG, INFO, WARN, ERROR or SYSERR as defined in LogInterface.
      messageText - The message text
      isModal - If true then a modal window will also appear and force the user to acknowledge the message.
      isLogged - Whether this message is written to a log file. Passed to the parent class.