ChrisMayfield/ThinkJavaCode2

Issue Rendering CardTable.java

nic-instruction opened this issue · 6 comments

Hello,

This is my first time teaching from your textbook, and I've enjoyed it a lot, but I'm running into a problem when running CardTable.java in Eclipse. It has no visible errors, but launches in the upper right-hand corner of the screen completely collapsed and doesn't render a deck when it is expanded.

From the Chapter 12 instructions I got the impression it would work out of the box and could then be used to implement a solitaire game. I've attached a picture for reference.

The example graphics code in the appendix runs without issue and I haven't had trouble implementing other assignments as examples. We were hoping to use this code as the basis for a class final project, so if there's a quick fix, let me know.

Thank you!
Screen Shot 2021-03-09 at 10 01 31 PM

I can't seem to reproduce the issue on my end. I tried running it from Eclipse on both my Mac laptop and Linux desktop, and in both cases, it shows the Card Table window correctly. I did notice a difference in the code from what we did in Chapters 15-17. Will you try changing Line 87 to frame.add(canvas); and let me know if that makes a difference on your end?

You're probably right. I changed the name of the folder and got the same result (no error message and an empty window in the upper left corner). I looked at the source code for ImageIcon, and it indeed ignores FileNotFoundException. As a result, the height and width of each image object are -1. Nice work, Swing. :) I don't know if it would help, but I'm using OpenJDK 11 on both of my machines. It might be a bug in the JDK if you're using a different version.

Unfortunately I got the same result with OpenJDK 11. (Picture attached).
I did realize that I'm on a fairly new version of eclipse:

Version: 2020-09 (4.17.0)
Build id: 20200910-1200

And my students are a version after me, so I went down the class path rabbit hole. For whatever reason it looks like the path only extends into the ch12 folder, and doesn't make it to the cardset-oxymoron folder at all, so I moved the folder out to the same level as the chapter folders, and then went into my project properties > Java Build Path > Source and added cardset-oxymoron to the source path. This appears to have worked!

Even being at the top level, the folder was not detected until I added it to the class path, so I don't know what the simple long-term solution to this problem is, but at least it's working!

Thank you so much for getting back to me so quickly, and for testing everything on your end, I really appreciate it!
Screen Shot 2021-03-10 at 1 49 17 PM
Screen Shot 2021-03-10 at 2 18 31 PM

You're welcome. I'll go ahead and close the issue since it's because of Eclipse configuration.