Javaru

Javaru

Kotlin Coroutine Confidence: Placeholder message does not appear (pg 41)

Pg 41 states “Run the code, and you’ll see the placeholder message in a small window, just like last time.” for the code astronomy/v4/src/main/kotlin/com/example/astronomy/AstronomyApplication.kt. However when I run this, I get the a blank JFrame. The “Loading your image…” JLabel does not show.

This is in the B3 version of the book with the example code downloaded on 2025-04-19 at 14:42 EDT.

book-kotlin-coroutine-confidence pragprog

Marked As Solved

sam-cooper

sam-cooper

Author of Kotlin Coroutine Confidence

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!

Where Next?

Popular Pragmatic Bookshelf topics Top

GilWright
Working through the steps (checking that the Info,plist matches exactly), run the demo game and what appears is grey but does not fill th...
New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
jskubick
I found an issue in Chapter 7 regarding android:backgroundTint vs app:backgroundTint. How to replicate: load chapter-7 from zipfile i...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
jonmac
The allprojects block listed on page 245 produces the following error when syncing gradle: “org.gradle.api.GradleScriptException: A prob...
New
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New
dachristenson
I’ve got to the end of Ch. 11, and the app runs, with all tabs displaying what they should – at first. After switching around between St...
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New

Sub Categories: