I’m making a swing application for myself and have been trying out a few different layouts. One thing that I’m having an issue with in all the layouts I’ve tried (BoxLayout, FlowLayout, BorderLayout, GroupLayout) is that I want to hide one of my elements, but I want to leave a blank space of the exact size in it’s place. At the moment, when the element disappears, or if I set the element as not visible on startup, then either the whole window is smaller, or something will happen like a textfield will expand to a rediculous size.
Specifying the sizes of the elements seem to have no effect at all.
Is there a way I can have an invisible element that still takes up it’s space in the layout?
Why are my elements not being given the sizes that I specify?
Grateful for any pointers.
Many thanks
Try
Box.createRigidArea. The description is simple enough:This creates a
Componentthat can be used in any layout.