FlowLayout for triangular region?

Discussion in 'Java' started by Mike Amling, Aug 8, 2009.

  1. Mike Amling

    Mike Amling Guest

    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
     
    Mike Amling, Aug 8, 2009
    #1
    1. Advertising

  2. Mike Amling

    Roedy Green Guest

    On Fri, 07 Aug 2009 20:37:57 -0500, Mike Amling <>
    wrote, quoted or indirectly quoted someone who said :

    > 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
     
    Roedy Green, Aug 8, 2009
    #2
    1. Advertising

  3. Roedy Green wrote:
    > On Fri, 07 Aug 2009 20:37:57 -0500, Mike Amling <>
    > wrote, quoted or indirectly quoted someone who said :
    >
    >> 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.
    >


    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.

    --

    Knute Johnson
    email s/nospam/knute2009/

    --
    Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
    ------->>>>>>http://www.NewsDemon.com<<<<<<------
    Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
     
    Knute Johnson, Aug 8, 2009
    #3
  4. Mike Amling

    Mike Amling Guest

    Roedy Green wrote:
    > On Fri, 07 Aug 2009 20:37:57 -0500, Mike Amling <>
    > wrote, quoted or indirectly quoted someone who said :
    >
    >> 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.


    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
     
    Mike Amling, Aug 8, 2009
    #4
  5. Mike Amling

    Roedy Green Guest

    On Fri, 07 Aug 2009 23:33:04 -0500, Mike Amling <>
    wrote, quoted or indirectly quoted someone who said :

    > 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
     
    Roedy Green, Aug 8, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nevets Steprock
    Replies:
    10
    Views:
    705
    Nevets Steprock
    Jun 14, 2005
  2. empire5
    Replies:
    8
    Views:
    303
    Juan T. Llibre
    Jan 14, 2007
  3. josh
    Replies:
    5
    Views:
    1,984
  4. T Koster

    Circular (triangular) structure reference

    T Koster, Feb 8, 2005, in forum: C Programming
    Replies:
    6
    Views:
    380
    infobahn
    Feb 8, 2005
  5. SAL

    #Region #End Region issue

    SAL, Aug 29, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    363
    Alexey Smirnov
    Aug 29, 2008
Loading...

Share This Page