I am having a problem getting the QuizCardPlayer program in Chapter 14 of the Head First Java Book to display the question that is reading from a file written out by QuizCardBuilder. I know the question is being read in and loaded into the ArrayList but it is not getting to the JTextArea. I have removed non related code. The example code below isolates the problem.
I can't get the text to display in the JTextArea. In the book there was a display.setText() command but I determined that it had nothing to do with that so I removed it and just tried the above. Still nothing. Could use some help - thanks....
You've got the JTextArea set to 50 columns wide, you've got the JScrollPane set to never show horizontal scroll bars, and you've got the JFrame 400 pixels wide. You don't do anything with the Font, so you'll get a 12-point font. Imagine that each character is 10 pixels wide; the 50-column text area is then 500 pixels wide, so there's 50 pixels that don't show on either side.
So, given that, perhaps you would like to try resizing the window to be somewhat wider, to see what happens...
Ok I set the font and set horizontal scrollbar policy to ALWAYS and fiddled around with the size of frame and display to come up with the following
which displays the text ok but I still don't understand the relationship between the frame size and JTextArea size that prevents it from displaying sometimes. Where can I get an education in this? Thanks for your help - this is better than a University!
Joined: Dec 17, 2005
For others who have the same problem I found that the following settings allow questions and answers of up to 30 chars to display ok.