Solved

Java Description

Posted on 2007-12-07
14
153 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
egit plugin on eclipse 8 82
Maven Project: Hibernate Dependencies Conflict 10 38
login form jsp example 2 37
American Express @Work site and Java 4 24
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

856 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