I'am trying to build a program that uses CardLayout and multiple JPanels. The problem I'am having is with JPanel sizes. How do I specify these component sizes? As far I'am aware of. SetSize() cannot be used when specifying component sizes. So what should I use to size them as I want?
I propably will have more problems coming with this. But lets go one at the time.
Ulf Dittmer wrote:You'd override the getPreferredSize, getMinimumSize and getMaximumSize methods as appropriate; especially getPreferredSize.
You don't need to override getPreferredSize(); once you call setPreferredSize, that will be the new preferred size. You can reset it to the automatically calculated version again by calling setPreferredSize(null).