Solved

Java Description

Posted on 2007-12-07
14
149 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now