This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!

Richard Sandmeyer

Greenhorn
+ Follow
since Jul 07, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Richard Sandmeyer

Thanks for the replies.

I just tried two of your suggestions: 1. enlarging the window by dragging the lower left corner further to the left and 2. making the labels visible (but misaligned) by changing to JLabel in the code. Both did as you mentioned, of course. Guess the simplest solution may be to use JLabel and experiment with ways to get the spacing of the instrument names to line up with the checkboxes; perhaps something as simple as picking a larger font for the instrument names would space them more neatly, or perhaps I'll have to find some other trick.

At least now I know that it isn't something wrong with my particular machine or copy of Java. It looks like "write once, run anywhere" may need to be qualified by adding "but don't expect quite the same results everywhere" at least when it comes to Swing.
12 years ago
Thanks for the replies.

I just tried two of your suggestions: 1. enlarging the window by dragging the lower left corner further to the left and 2. making the labels visible (but misaligned) by changing to JLabel in the code. Both did as you mentioned, of course. Guess the simplest solution may be to use JLabel and experiment with ways to get the spacing of the instrument names to line up with the checkboxes; perhaps something as simple as picking a larger font for the instrument names would space them more neatly, or perhaps I'll have to find some other trick.

At least now I know that it isn't something wrong with my particular machine or copy of Java. It looks like "write once, run anywhere" may need to be qualified by adding "but don't expect quite the same results everywhere" at least when it comes to Swing.
12 years ago
This question will only make sense to those who are familiar with the book "Head First Java" by Sierra and Bates. I'm quite new to Java (though not to C++ and some older languages), and I have found that working my way through the book seems to be a good way to learn it. I've been running the code examples on Mac OS X 10.4.10 on a G4 Powerbook using Java 1.5.0_07. Everything went well until I got to the BeatBox example in Chapter 13 (Code Kitchen).

The BeatBox is supposed to display a GUI window (frame) consisting of three sections, west is a box with a vertically-stacked list of musical instrument names, center is a 16 by 16 array of checkboxes, and east is a box of four vertically-stacked buttons. Problem is that when I compile and run it, the center panel overwrites the west panel section so that there is blank space where the column of names should be. This seems to be a problem with the Mac implementation of Swing as I ported the *.java file to a PC (Windows XP Home, Java 6) and compiled and ran it there with no problem. BTW, I had this problem with the downloaded BeatBox source in the Code Kitchens jar; so this problem isn't a typing error on my part.

My questions are: Has anyone else encountered this problem and is there a simple fix? Is it really (as I suspect) a problem with Swing on Mac? If so, has a fix to Swing on Mac been put out yet?

TIA for any help.
12 years ago
This question will only make sense to those who are familiar with the book "Head First Java" by Sierra and Bates. I'm quite new to Java (though not to C++ and some older languages), and I have found that working my way through the book seems to be a good way to learn it. I've been running the code examples on Mac OS X 10.4.10 on a G4 Powerbook using Java 1.5.0_07. Everything went well until I got to the BeatBox example in Chapter 13 (Code Kitchen).

The BeatBox is supposed to display a GUI window (frame) consisting of three sections, west is a box with a vertically-stacked list of musical instrument names, center is a 16 by 16 array of checkboxes, and east is a box of four vertically-stacked buttons. Problem is that when I compile and run it, the center panel overwrites the west panel section so that there is blank space where the column of names should be. This seems to be a problem with the Mac implementation of Swing as I ported the *.java file to a PC (Windows XP Home, Java 6) and compiled and ran it there with no problem. BTW, I had this problem with the downloaded BeatBox source in the Code Kitchens jar; so this problem isn't a typing error on my part.

My questions are: Has anyone else encountered this problem and is there a simple fix? Is it really (as I suspect) a problem with Swing on Mac? If so, has a fix to Swing on Mac been put out yet?

TIA for any help.
12 years ago