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

jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New
conradwt
First, the code resources: Page 237: rumbl_umbrella/apps/rumbl/mix.exs Note: That this file is missing. Page 238: rumbl_umbrella/app...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
New
swlaschin
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
dachristenson
@mfazio23 Android Studio will not accept anything I do when trying to use the Transformations class, as described on pp. 140-141. Googl...
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
New
New
New

Sub Categories: