I'm developing a JFrame that will add some components dynamically. When i add a new component, i want all components that are below, to be shifted down, and when i remove it, i want everything to return as it was.
Is there a specific LayoutManager to use in order to fulfill my requirements ?
Try putting all your Components into a List; add to and remove from the position 0 in the List. Whenever you add a Component, remove everything, then replace everything by going through the List; use the index value to set the gridy value of the Constraints, then call validate(). Whenever you remove a Component, you will have to remove it from the List and the JFrame, then again go through the indices to set up the gridy value.
Alternative suggestion:- You may be able to use a GridLayout with one column instead and always add or remove at index 0. [ March 28, 2007: Message edited by: Campbell Ritchie ]