'Anchor' component to the right of a row of components in GridBagLayout

I want to display a list of components graphically across the screen in a row. I'm currently attempting to do this with the Grid Bag Layout manager. Additonally, the button to create a new component is just another component and is also included in the row. However, I want the button to always be the right most component. I've illustrated what I mean in the mock-ups below.Example One

The example above is before a component was added, and the example below is after.

Example Two

The only solution I can see is to manually remove and re-add the Creation button every time a component is added, but I'd like to find a more elegant way of fixing this than that.

1 answer

  • answered 2018-01-14 05:00 Jeremy

    I solved this by removing the component before I added a new one, and then just adding it again after the new component was added.