Need: Output a Java application’s log into a GUI component, such as a JTextArea.
Concern: Need to log things from any class, in a static manner. However, the GUI logger component must not be static (obviously) as it’s the member of a parent component.
What should I do?
Create a singelton log provider and add the “textfield” as a listener to it.
Example of the logger singelton:
Add your listener (which you will need to implement yourself) like this:
And use it (from any class) like this:
Or you can use a package like log4j.