Solved

Java Description

Posted on 2007-12-07
14
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

733 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