• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

awt problem

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

it compile and run but nothing is visible
but
this one is visible

Now in grid layout

it has to be two row and one column but showing 2 x 2 matrix why?
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Payal,
In your first two codes you are running into the difference between LayoutManager and LayoutManager2. The containers that implement LayoutManager2 require constraints to be supplied in order to perform the layout.
In your first code example, you have not supplied any constraints while adding your components, which is not required by FlowLayout. Then you switch your layout to BorderLayout and the layout doesn't have any constraints for the components. Therefore you see no components being layed out!
In your second code example you are doing the opposite. In that case the FlowLayout just ignores your constraints and doesn't its own layout.
Your last question regarding GridLayout. The reason for the name is that the entire contents is divided up into equal sized grids. There will always be the number of rows and cols that you specify in the creation. There are specific rules on what will happen if you add more components then you have grids. Please see the API documentation for that explanation. NOTE: GridBagLayout will allow you to have any number of grids of any size in a layout!
Regards,
Manfred.
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RHE says that the Grid Layout will behave unpredictably when we add more or less components than the no of cells created.
Is it anything to do with that..
comments pls..
 
tvs sundaram
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For your first question it is about new layout querying the previous layout regarding the components added to it.
The layouts implementing Layoutmanager will query the previous layout. i.e flow, Grid
layouts implementing LayoutManager2 will not query the previous layout manager regarding the components added. They will start afresh in the screen and will add components only after that. i.e,border, card, gridbag
With this reasoning if u analyse your question the answer will be clear.
HTH
any comments/ corrections welcome.
reply
    Bookmark Topic Watch Topic
  • New Topic