You’re absolutely right, the message is missing here for me too. It must have been working when I originally wrote and tested the code, so I’ll have to go back and see where the problem crept in.
To fix this one, we can add a call to window.revalidate()
after adding the JLabel
:
class ImageViewer : WindowAdapter() {
override fun windowOpened(e: WindowEvent) {
val window = e.window as JFrame
window.add(JLabel("Loading your image…", JLabel.CENTER))
window.revalidate()
// TODO: download and display an image
}
}
Let me know if this fixes the code for you. I’ll do a little more digging to make sure I understand how I missed the problem. Thank you so much for spotting the issue and letting me know about it!