0

In many cases, a GroupLayout may include pieces with simple structures. For example, it seems sensible to write something like an AlignedStack object that would allow the user to put together a bunch of components/groups/gaps making up a left/center/right-aligned vertical or top/center/bottom aligned horizontal "stack" and then retrieve the resulting horizontal and vertical groups. I can surely write what I need myself (it seems like fairly trivial boilerplate), but I'm wondering if anyone's built a package of such things so I don't have to.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
dfeuer
  • 48,079
  • 5
  • 63
  • 167
  • *"something like an `AlignedStack`"* DYM like seen in [this answer](http://stackoverflow.com/a/21659516/418556)? I've never heard of an `AlignedStack`, link to documentation. – Andrew Thompson Apr 13 '14 at 04:37
  • Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow; can you be more specific? – trashgod Apr 13 '14 at 12:44

3 Answers3

1

Not sure I understand what an "aligned stack" is, but if I do then you should be able to use a BoxLayout. It does horizontal and vertical positioning and components can be top/bottom or left/right aligned.

Read the section from the Swing tutorial on How to Use Box Layout for more information and working examples.

camickr
  • 321,443
  • 19
  • 166
  • 288
  • A `BoxLayout` has to lay out its own `Container`. That's certainly an option, but in this case it seems more natural to me to have two `BoxLayout`-like `Group`s as part of a `GroupLayout`. – dfeuer Apr 13 '14 at 02:13
1

Several approaches are common:

  • This example nests panels having GroupLayout in a panel having a vertical BoxLayout.

  • This example illustrates how to add rows dynamically to a panel having GroupLayout.

  • The NeBeans and Eclipse GUI editors are useful for experimenting; examine the generated code to see the effect.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

Try Eclipse WindowBuilder ( https://www.eclipse.org/windowbuilder/ ). It can build any swing layout for you, featuring a pretty smart code parser / generator, all swing components and layouts, and an easy to use drag and drop / property based editor. I think it will suit your needs.

DankMemes
  • 2,085
  • 2
  • 21
  • 30
  • This does not relate to the question I intended to ask. Such an editor will *not* meet my needs for this particular layout. – dfeuer Apr 13 '14 at 02:16
  • How so? I'm sorry but from your question I assumed you needed a "tool." What do you actually want? If you have already tried windowbuilder please explain why it doesn't meet your needs. If not, please try it before assuming it won't work. – DankMemes Apr 13 '14 at 14:20