This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

GridLayout question......  RSS feed

 
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
 
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.
 
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..
 
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 ...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!