Closed UltraBurstXD closed 4 years ago
You can set bounds of the component in container only when it doesn't have a layout (has a null
layout). Panels do have a layout by default - BorderLayout
in case of WebLaF - that is why your button fills the whole panel size and ignores your bounds.
To position components it is recommended to use layout managers that are available in Swing and many 3rd-party libraries. I recommend checking official tutorial on layout managers here: https://docs.oracle.com/javase/tutorial/uiswing/layout/index.html
You can also create your own layout manager (although usually it is not needed as existing ones already cover most possible use cases) to dynamically update positioning of the components on the container as it's size changes or components get added or removed from it.
Understood, thanks for the help.
Hello Mgarin,
I'm having problems setting the bounds of WebButton component. I'm trying to use the convenient way - setBounds(), to no avail. It fills the whole panel. Is there a another method that I'm missing?