Originally posted by Campbell Ritchie:
The instrument names showed when I tried it, and the GUI filled my screen (I only use 1280*1024). There seemed to be a two-dimensional array of checkboxes, which I don't think you intended however.
Originally posted by Ken Blair:
This belongs in the Swing forum.
Also posted by Ken Blair:
The behavior is expected if the window is too small for all of it's contents. Off the top of my head I'm not aware if setBounds() will trigger layout validation. If it doesn't, you need to call validate() yourself to cause the frame to have it's components arranged after you change it's size through setBounds().
Originally posted by Adam Price:
Hmm..I added theFrame.validate. It didn't work. Rats.
I tried forcing nameBox to be visible (nameBox.setVisible(true) and I tried re-validating nameBox as well. Neither attempt worked.
I did notice, though, that it may not be a size issue. If I resize the window so it is smaller, that will also cause the instrument names to appear. In fact, if I minimize then maximize the window or dock the window and undock it, the names will appear. Moving the window does not work. How do I get this thread moved to swing?
Originally posted by Ken Blair:
That's (probably) because all of those cause layout to occur. If you change the size of the frame but don't force the layout to be recalculated then nothing is going to change. All of the things you've mentioned doing at runtime as a user cause this to happen. Programmatically changing the size doesn't.
Try validating the content pane, not the frame. Or calling validateTree().
Originally posted by Brian Cole:
Your code works as-is on my machine, though
the window pops up way to huge. (It looks better
with theFrame.pack() over theFrame.setSize().)
It's hard to know where things are going wrong
for you if I can't reproduce it, but does it
help any if you use GridLayout for nameBox?
//Box nameBox = new Box(BoxLayout.Y_AXIS);
JPanel nameBox = new JPanel(new GridLayout(INSTRUMENT_COUNT, 0, 2, 1));
It shouldn't but you never know. Something
else you can try is replacing main() with:
public static void main(String[] args) {
final BeatBox bb = new BeatBox();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
bb.buildGUI();
}
});
}
Originally posted by Adam Price:
Bizarre - neither of these has any effect.
Originally posted by Adam Price:
to no avail. I removed the explicit setBounds. I removed the border. Arrghhhh!
I tried and , but was told
in both cases. Arrrgghh!
Originally posted by Brian Cole:
Does the unmodified headfirst beatbox work
ok for you? If so, what are the differences? I do
not have access to the headfirst book.
Originally posted by Ken Blair
[QB]That's because you shouldn't use validateTree(), it was a stupid thing for me to say. Really stupid in fact seeing as validate() calls validateTree() in the first place. This example works fine for me when I compile it. Have you tried just copying what you posted here over to a new file? Sometimes we get so caught up trying to solve a problem we inadvertently introduce a new one without realizing it that masks the first one being solved.
If it still happens I'd start to wonder about your OS, JDK and L&F.[qb]
Originally posted by Brian Cole:
Well we should be able to determine if it is a problem with the LnF. Do you still have a problem if you use this main() method?
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
new BeatBox().buildGUI();
}
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|