FlowLayout for triangular region?

M

Mike Amling

I want to place Buttons of various widths in the area above the main
diagonal of a rectangular Container, something like


------------
| Ab C Def |
|. G Hi J K|
|.. Lm No |
|... Pqr St|
|.... Uvw X|
|..... Y |
|...... |
|....... |
|........ |
|......... |
|..........|
------------


The dots would not be drawn on the screen. I've put them in the
illustration just to show the location of the main diagonal.
I don't know of any way to get FlowLayout to flow into a shape other
than a rectangle. GridLayout could probably be made to work if the
Buttons all had the same width.
Is there a way to do this without placing the Buttons manually or
writing a custom Layout Manager?

--Mike Amling
 
R

Roedy Green

I don't know of any way to get FlowLayout to flow into a shape other
than a rectangle. GridLayout could probably be made to work if the
Buttons all had the same width.
Is there a way to do this wit

Over ride the method that assigns x,y to each component in FlowLayout.
It will be almost the same logic.

Wherever you need it referring the width of the region, or 0 you may
will need a formula.

--
Roedy Green Canadian Mind Products
http://mindprod.com

"We must be very careful when we give advice to younger people: sometimes
they follow it!"
~ Edsger Wybe Dijkstra, born: 1930-05-11 died: 2002-08-06 at age: 72
 
K

Knute Johnson

Roedy said:
Over ride the method that assigns x,y to each component in FlowLayout.
It will be almost the same logic.

Wherever you need it referring the width of the region, or 0 you may
will need a formula.

You might also look at Box and BoxLayout. Another option might be to
put dummy components of increasing width on the left of the components
you want to display.
 
M

Mike Amling

Roedy said:
Over ride the method that assigns x,y to each component in FlowLayout.
It will be almost the same logic.

OK. I overrode FlowLayout.layoutContainer(final Container parent). It
wasn't as bad as I thought it would be.
Wherever you need it referring the width of the region, or 0 you may
will need a formula.

--Mike Amling
 
R

Roedy Green

OK. I overrode FlowLayout.layoutContainer(final Container parent). It
wasn't as bad as I thought it would be.


That was my impression too. Just because you are overriding built-in
code you get the impression it is going to have to be complicated. All
you are doing is assigning x,y and sizes to each component given the
size of the container and the 3 ways to measure desired size of each
component.

You can pass extra custom parms in with each component, a la
GrigBagLayout if you need some tweaking.

It is great to have some code samples to look at so you can see just
what you need to do.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"We must be very careful when we give advice to younger people: sometimes
they follow it!"
~ Edsger Wybe Dijkstra, born: 1930-05-11 died: 2002-08-06 at age: 72
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top