[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Java Description

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
gauravflame
Asked:
gauravflame
  • 4
  • 4
  • 4
  • +1
3 Solutions
 
gauravflameAuthor Commented:
Rephrasing it is look like

contentpane.add( BPanel , BorderLayout.CENTER ) ;  // put on the content pane
BPanel.setLayout( new GridLayout( 5, 3, 5, 5  ) );
   
0
 
CEHJCommented:
2 rows, 3 cols, 4 x pixels space, 5 y pixels space
0
 
objectsCommented:
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
Independent Software Vendors: 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!

 
objectsCommented:
> BPanel.setLayout( new GridLayout( 5, 3, 5, 5  ) );

Thats setting the layout of BPanel to be a 5 x 3 grid
0
 
objectsCommented:
And 5 pixel gap between cells
0
 
CEHJCommented:
(Make the necessary adjustments since yours ;-))
0
 
ksivananthCommented:
2 number of rows, 3 number of columns, 4 horizontal gap between cells, 5 vertical gap between cells
0
 
gauravflameAuthor Commented:
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
 
objectsCommented:
no, content pane uses a border layout.
BPanel by default would use a flow layout
0
 
gauravflameAuthor Commented:
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
 
ksivananthCommented:
>>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
 
CEHJCommented:
>>
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
 
gauravflameAuthor Commented:
Thanks all clear :)


0
 
CEHJCommented:
:-)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 4
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now