• Post Reply Bookmark Topic Watch Topic
  • New Topic

Kind of like FlowLayout, but with new lines?

 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want a properties form. It has a label "Width:" and then a box where you can enter width. Using FlowLayout, it takes ~10 lines of code, but is all in a line. I used spring layout to make each property be on it's own line, but it took way more code then it ought to have. Is there any kind of layout like flow layout, but where I can specify where the new line begins? It seems so obvious. Grid layout is out of the question because it looks preposterous.

Thanks,
Nick
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are basically two other options:

1) Using GridBagLayout, which is supremely powerful, but unpleasantly complex. Grown men have been known to weep at the feet of GridBagLayout.

2) Use nested layouts. Instead of one panel, use multiple panels. For example, for each row, use a JPanel containing a label and a textfield; add these rows to another JPanel with a vertical BoxLayout.
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually considered doing that, but I figured, why would they make all these layouts, but not make the most simple/useful one?

Anyway, thanks.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember long, long ago, back before the Earth's crust had cooled, and Java had just come out, someone wrote a LayoutManager that emulated the Tk "packer". I know I used it myself; It was pretty much what you're asking for.

I Googled "PackLayout" and I found a bunch of pointers to Netscape's IFC classes (oh lord, remember that?) I couldn't find a source for the actual IFC itself, but I bet you could if you looked around... It looks like another implementation of the same idea.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!