• Post Reply Bookmark Topic Watch Topic
  • New Topic

GridLayout question......  RSS feed

 
sonir shah
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I tried running this code and I found that 3 buttons are displayed above and 2 buttons are displayed below.But when the layout manager is given, then it should display all the buttons side by side and if due to lack of space it should go in the next line.
Am I right??
Sonir
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the other way.
when u say in gridlayout (2,1) , it means 2 rows 1 coloumn. so it will put 2 button one above another then it will run out of space, so it will put next to it 2 more buttons, run out of space again, and will move another line and put 1 more button.
so u get 3 above 2.
 
R K Singh
Ranch Hand
Posts: 5390
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case of Added comp more than no of cells in GridLayout:
it is gridLayout when no of components being added is more then it can occupy then it adds column to occupy them.

In case of Added comp less than no of cells in GridLayout:
then it try to fill all rows.
By default it adds comp to first rows first and then second and third .. and so on ..
Sonir I think first you go through some book like RHE or Khalid... then go for mocks
time might be less ... so you have to run much faster than any one else..
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
keep this rule in mind while dealing with GridLayout...
if ( nr > 0 )
nc = (ncomp+nr-1)/nr
else
nr = (ncomp+nc-1)/nc
where,
nr = number of rows specified at layout creation,
nc = number of columns specified at layout creation,
ncomp = total components u have actually.
i read this
Here
regards
maulin
 
R K Singh
Ranch Hand
Posts: 5390
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maulin
thanks a lot !!
I did not know this ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!