How to handle exception messages in GUI applications in order to decouple application code to GUI code?

I want to make an application with a GUI in a way that most of its code is independent from the GUI used (let’s say I’ll use Java 8 and Swing for example). I have some methods with try/catch blocks which print exceptions messages on screen (for example with System.err.println() or printStackTrace()). How can I show those messages in the GUI without modifying the method code? I know I could call a GUI related method in the catch block, but doing this I would tie my code to a specific GUI, whereas my goal is to reach independence (decouple the “back-end” code from the GUI). What is the preferred approach to do this? Thanks in advance.