• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Layout

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I thought that the initial layout which is borderLayout when changed to FlowLayout should not show any buttons which was added to the borderLayout.... but I'm wrong.... the Frame shows 5 buttons arranged from left to right.....
What Am I missing.... Can anyone clearly explain when does the above situation happen....
Thx in advance
Aruna
[This message has been edited by Aru Ven (edited November 14, 2000).]
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Whenever the default Layout is changed then the Components will be laid out "only" as per the new layout.
For example, the default Layout for Frames is "BorderLayout" and as per your code, first the default "BorderLayout" is changed to "FlowLayout". Hence, all the 5 Components (buttons) are laid in a single row from Left to Right.
When you change it again to BorderLayout, the Components will not assume the BorderLayout positions. They still occupy the positions as per FlowLayout.
But, you can always change it to any Layout other than the default BorderLayout i.e, you can change the layout from FlowLayout to even GridLayout but not to "BorderLayout" in any case.
I added extra lines to your code to change the layout. You can try this by removing the comment lines...
....
public fra7()
{
setLayout(new BorderLayout());
add(bSouth, "South");
add(bWest, "West");
add(bEast, "East");
add(bNorth, "North");
add(bCenter);
setLayout(new FlowLayout()); // 1 Layout changes
setLayout(new BorderLayout()); // 2 Does not change
setLayout(new FlowLayout()); // 3 Layout changes
setLayout(new BorderLayout()); // 4 Does not change
setLayout(new FlowLayout()); // 5 Layout changes
setLayout(new GridLayout(2, 3)); // 6 Layout changes
setLayout(new FlowLayout()); // 7 Layout changes
setLayout(new BorderLayout()); // 8 Does not change
setSize(200, 200);
setVisible(true);

}
.....
- Suresh Selvaraj
 
Aru Ven
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suresh, Gautaum
Thx for ur responses.
Suresh, I'm still not clear. Please look at the code below.

When executed an empty frame is displayed.
So should I assume that.....
If the default layout is changed to any other layout then the components added to the default layout are visible even though they are not added to the new layout.
But the converse is False.... meaning.. example
when A frame has a Flowlayout to which the components are added then if the layout is changed to the default...border layout...then the components added to the flow layout are not visible.
The components should be explicitly added to the layout to be visible...
Am I right........???
Thx in advance
Aruna

[This message has been edited by Aru Ven (edited November 15, 2000).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic