• 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

Grid layout.

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Applied Reasoning #36
A panel has a GridLayout with 2 rows and 2columns.There is a button in each of the cells and another button is added as follows.
aPanel.add(new Button("bob"));
Where will the Button be placed.
a)row 1 column 3
b)row 1 column 1
c)row 3 column 1
d)row 2 column 3
e)row 2 column 2
Ans given e
My ans d.
In explanation to ans they have specified that
When a component is added to the full GridLayout, anew column is added.
If this is true, new button has to come at row 2 column 3 , am i right??

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mani:
the answer e is correct....
Check this code :

Also, RHE mentions in the book that when a grid layout
has to manage either fewer number or components or much
more components than the allocated number of spaces, strange
behaviour may be seen in some cases.
Btw, the output will be:

Button # 0 Button # 1 Button # 2
Button # 3 Button # 5

Regds.
- satya

[This message has been edited by satya5 (edited May 01, 2000).]
 
Mani
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So can I take like this,
If we add more components to a GridLayout than its no: of rows or columns, extra components will be placed above the last column of the last row.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mani:
I would not want to make any generalised statements here.
However, for your intrest, I would suggest the following:
take the code above and play around doing these:
1. change the value used in the for loop (i < 4)
say make it 10 and see what happens.
2. change the grid layout size (2,2) to someother size
say (5,6).
3. or what ever you think is appropriate.
such things would make you have your own opinion, rather than
assuming people like me (excluding the bartenders and sherrifs) are correct with their statements.
Actually, this weekend I was doing this.
Please don't take me in a wrong sense.
Regds.
- satya
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi mani,
when we try to add extra components then, new columns are added to accomadate those components. after the columns are added, the components are rearranged like how normally the grids are filled(row wise)
regards,
priya
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic