You can use append to add instead of replacing. This is the easy part.
The hard part: you need to change the program flow. In Swing, there is one thread for dispatching GUI events, an event dispatch thread. You should not set EDT to sleep or perform any other lengthy operations in it. This will freeze the graphical interface, it will not be able to answer anything and will not be redrawn.
Instead, you should either start a new thread for the logical threads and send operations that must be performed on the EDT (anything that manipulates the GUI) using SwingUtilities.invokeLater or, in this case, perhaps better, SwingUtilities.invokeAndWait .
Or you should take an event-driven managed thread, for example. you can use Timer to display the second text later.
A program thread that works well with single-threaded console programs is not suitable for multi-threaded GUI applications (and each GUI application is automatically multi-threaded).
source share