Solved

Java Description

Posted on 2007-12-07
14
152 Views
Last Modified: 2010-03-30
Can anyone explain below line of code
and
What is here 2,3,4,5 means ?
=============================
BPanel.setLayout( new GridLayout( 2, 3, 4, 5  ) );

0
Comment
Question by:gauravflame
  • 4
  • 4
  • 4
  • +1
14 Comments
 

Author Comment

by:gauravflame
ID: 20426688
Rephrasing it is look like

contentpane.add( BPanel , BorderLayout.CENTER ) ;  // put on the content pane
BPanel.setLayout( new GridLayout( 5, 3, 5, 5  ) );
   
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 150 total points
ID: 20426692
2 rows, 3 cols, 4 x pixels space, 5 y pixels space
0
 
LVL 92

Assisted Solution

by:objects
objects earned 150 total points
ID: 20426695
2 row x 3 column grid
with 4 pixel gap between cells horizontally
and 5 pixel gap between cells verically

http://java.sun.com/javase/6/docs/api/java/awt/GridLayout.html#GridLayout(int,%20int,%20int,%20int)
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 92

Expert Comment

by:objects
ID: 20426698
> BPanel.setLayout( new GridLayout( 5, 3, 5, 5  ) );

Thats setting the layout of BPanel to be a 5 x 3 grid
0
 
LVL 92

Expert Comment

by:objects
ID: 20426701
And 5 pixel gap between cells
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20426702
(Make the necessary adjustments since yours ;-))
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 20426723
2 number of rows, 3 number of columns, 4 horizontal gap between cells, 5 vertical gap between cells
0
 

Author Comment

by:gauravflame
ID: 20426754
Why to use GridLayout ? Buttons are arranged for BPanel from BorderLayout
BPanel.setLayout( new GridLayout( 5, 3, 5, 5  ) );

Observation ::
If I comment out Gridlayout  line of code everything on contentpane become scatter
0
 
LVL 92

Expert Comment

by:objects
ID: 20426770
no, content pane uses a border layout.
BPanel by default would use a flow layout
0
 

Author Comment

by:gauravflame
ID: 20426798
I think by Default layout manager is Border Layout in Java swing

My Question If  BPanel setting itself to Border layout why it is need to set on Grid Layout.
or It is to deal with good interface

0
 
LVL 26

Accepted Solution

by:
ksivananth earned 200 total points
ID: 20426816
>>I think by Default layout manager is Border Layout in Java swing

 it depends the container. For e.g., JFrame and JDialog uses BorderLayout and JPanel uses FlowLayout.

>>If  BPanel setting itself to Border layout why it is need to set on Grid Layout.

If BPanel is a JPanel, it will use the FlowLayout which lays the component row and wrapps if the size doesn't fit and you won't have control. grid gives you some control to render the component int tabuler format!

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20426830
>>
My Question If  BPanel setting itself to Border layout why it is need to set on Grid Layout.
or It is to deal with good interface
>>

Because a BorderLayout wouldn't lay out the buttons in a neat grid
0
 

Author Comment

by:gauravflame
ID: 20426837
Thanks all clear :)


0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20426886
:-)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question