<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ankit Virparia &#187; Layout</title>
	<atom:link href="http://ankit.co/tag/layout/feed" rel="self" type="application/rss+xml" />
	<link>http://ankit.co</link>
	<description>A Programmer, Designer and Trainer</description>
	<lastBuildDate>Sun, 11 May 2014 04:15:47 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>CardLayout</title>
		<link>http://ankit.co/tutorials/java-tutorials/layouts/cardlayout?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cardlayout</link>
		<comments>http://ankit.co/tutorials/java-tutorials/layouts/cardlayout#comments</comments>
		<pubDate>Sat, 12 Jan 2013 13:14:24 +0000</pubDate>
		<dc:creator><![CDATA[Ankit Virparia]]></dc:creator>
				<category><![CDATA[Layouts]]></category>
		<category><![CDATA[CardLayout]]></category>
		<category><![CDATA[Layout]]></category>

		<guid isPermaLink="false">http://ankit.co/?p=448</guid>
		<description><![CDATA[<p>CardLayout is used to change the content of an application without opening a new Frame. For example, Login panel can be changed to Logout panel once user gets logged in. Steps to apply CardLayout 1) Create a Panel(named: cardPanel) and set its layout to CardLayout. 2) Add another Panels(named: firstP, secondP, thirdP) to cardPanel as [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/layouts/cardlayout">CardLayout</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>CardLayout is used to change the content of an application without opening a new Frame. For example, Login panel can be changed to Logout panel once user gets logged in.</p>
<h2>Steps to apply CardLayout</h2>
<p>1) Create a Panel(named: cardPanel) and set its layout to CardLayout.<br />
2) Add another Panels(named: firstP, secondP, thirdP) to cardPanel as a Card. Give unique name to each panel.<br />
3) Call CardLayout.show(cardPanel, &#8220;name of card&#8221;); to make desired card visible.</p>
<p><strong>Program:</strong></p>
<pre class="brush: java; title: ; notranslate">
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;

public class CardLayoutDemo extends Applet implements ActionListener
{
  Panel cardPanel;        
  Panel firstP, secondP, thirdP;  
  Panel buttonP;                  
  Button first, second, third;    
  CardLayout ourLayout;           
  
  public void init()
  {
    cardPanel = new Panel();
    ourLayout = new CardLayout();    
    cardPanel.setLayout (ourLayout);
	
    firstP = new Panel();
    firstP.setBackground(Color.blue);
    
    secondP = new Panel();
    secondP.setBackground(Color.yellow);
    
    thirdP = new Panel();
    thirdP.setBackground(Color.green);
    
    first = new Button(&quot;First&quot;);
    first.addActionListener(this);
    
    second = new Button(&quot;Second&quot;);
    second.addActionListener(this);
    
    third = new Button(&quot;Third&quot;);
    third.addActionListener(this);
    
    buttonP = new Panel();   // Panel's default Layout manager is FlowLayout
    buttonP.add(first);
    buttonP.add(second);
    buttonP.add(third);
    
    this.setLayout(new BorderLayout());
    this.add(buttonP, BorderLayout.SOUTH);
    this.add(cardPanel, BorderLayout.CENTER);
    
    cardPanel.add(firstP, &quot;First&quot;);     //blue
    cardPanel.add(secondP, &quot;Second&quot;);   //yellow
    cardPanel.add(thirdP, &quot;Third&quot;);     //green
    
  }
  
  
  public void actionPerformed(ActionEvent e)
  {
    if (e.getSource() == first)
      ourLayout.show(cardPanel, &quot;First&quot;);
      
    if (e.getSource() == second)
      ourLayout.show(cardPanel, &quot;Second&quot;);
      
    if (e.getSource() == third)
      ourLayout.show(cardPanel, &quot;Third&quot;);
  }
}

/*
&lt;applet code=&quot;CardLayoutDemo&quot; width=&quot;500&quot; height=&quot;500&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><br />
<applet class="AppletBorder" code="CardLayoutDemo.class" width="500"  CODEBASE="../../../classes/" height="300"></applet> </p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/layouts/cardlayout">CardLayout</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ankit.co/tutorials/java-tutorials/layouts/cardlayout/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Layout or null Layout</title>
		<link>http://ankit.co/tutorials/java-tutorials/layouts/custom-layout-or-null-layout?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=custom-layout-or-null-layout</link>
		<comments>http://ankit.co/tutorials/java-tutorials/layouts/custom-layout-or-null-layout#comments</comments>
		<pubDate>Sat, 12 Jan 2013 12:22:15 +0000</pubDate>
		<dc:creator><![CDATA[Ankit Virparia]]></dc:creator>
				<category><![CDATA[Layouts]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[NullLayout]]></category>

		<guid isPermaLink="false">http://ankit.co/?p=444</guid>
		<description><![CDATA[<p>&#8220;null&#8221; is a keyword of java. This tutorial is not about a any java class. And it&#8217;s also not about setting some layout. This is to remove the existing layout! And by removing the layout one can do the exact positioning of the components. We can remove the existing layout by calling a method: setLayout(null); [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/layouts/custom-layout-or-null-layout">Custom Layout or null Layout</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>&#8220;null&#8221; is a keyword of java. This tutorial is not about a any java class. And it&#8217;s also not about setting some layout. This is to remove the existing layout! And by removing the layout one can do the exact positioning of the components. </p>
<p>We can remove the existing layout by calling a method: setLayout(null); and then even if we try to components, that will not be displayed. To make component visible we need to invoke seBounds(x_cord, y_cord, width, height) method on all the components. </p>
<p><strong>Program:</strong></p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class NullLayoutDemo extends Applet
{
	Button b1, b2, b3;
	public void init()
	{
		setBackground(Color.green);
		setLayout(null);
		
		b1 = new Button(&quot;Button1&quot;);
		b2 = new Button(&quot;Button2&quot;);
		b3 = new Button(&quot;Button3&quot;);
		
		add(b1);
		add(b2);
		add(b3);
		
		b1.setBounds(50,100, 150, 50);
		b2.setBounds(50,200, 150, 50);
		b3.setBounds(50,300, 150, 50);
	}	
}
/*
&lt;applet code=&quot;NullLayoutDemo&quot; width=&quot;500&quot; height=&quot;500&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><br />
<applet class="AppletBorder" code="NullLayoutDemo.class" width="500"  CODEBASE="../../../classes/" height="300"></applet></p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/layouts/custom-layout-or-null-layout">Custom Layout or null Layout</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ankit.co/tutorials/java-tutorials/layouts/custom-layout-or-null-layout/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BorderLayout</title>
		<link>http://ankit.co/tutorials/java-tutorials/layouts/borderlayout?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=borderlayout</link>
		<comments>http://ankit.co/tutorials/java-tutorials/layouts/borderlayout#comments</comments>
		<pubDate>Sat, 12 Jan 2013 07:40:18 +0000</pubDate>
		<dc:creator><![CDATA[Ankit Virparia]]></dc:creator>
				<category><![CDATA[Layouts]]></category>
		<category><![CDATA[BorderLayout]]></category>
		<category><![CDATA[Layout]]></category>

		<guid isPermaLink="false">http://ankit.co/?p=437</guid>
		<description><![CDATA[<p>java.awt.BorderLayout is the Layout which divides component area into 5 parts which are CENTER, NORTH, SOUTH, EAST, WEST. BorderLayout is used to setup an application having contant top/bottom/left/right part. It re sizes the components added in it. Component add sequence do not play an important role. If we normally add a component in it. By [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/layouts/borderlayout">BorderLayout</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>java.awt.BorderLayout is the Layout which divides component area into 5 parts which are CENTER, NORTH, SOUTH, EAST, WEST. BorderLayout is used to setup an application having contant top/bottom/left/right part. It re sizes the components added in it. Component add sequence do not play an important role. If we normally add a component in it. By default it will be added in CENTER part. To set any layout of any component the method which can be used is: <strong>componetObject.setLayout(layoutManagerObject);</strong> We have only a default constructor in java.awt.BorderLayout class.</p>
<hr/>
As discussed above, We have 5 sub parts of this Layout. By default the components goes to CENTER part and replaces the previously added component. BorderLayout can accommodate at max only 5 components. To add a component in specific direction e.g. NORTH the syntax is:   <strong>add(btn, BorderLayout.NORTH);</strong> So, A point to remember is: In  case of BorderLayout, we need to use add() method which takes 2 arguments. One is the component to be added and another is the direction as integer. As a second argument a static int from BroderLayout can be passed as discussed below:   </p>
<h2>borderLayout with normal add() method</h2>
<p><strong>Program:</strong></p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class BorderLayoutDemo extends Applet
{
	Button b1, b2, b3;
	public void init()
	{
		BorderLayout bl = new BorderLayout(20,20);
		setLayout(bl);
		
		b1 = new Button(&quot;Button1&quot;);
		b2 = new Button(&quot;Button2&quot;);
		b3 = new Button(&quot;Button3&quot;);
		
		add(b1);
		add(b2);
		add(b3);
	}	
}
/*
&lt;applet code=&quot;BorderLayoutDemo&quot; width=&quot;500&quot; height=&quot;500&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><br />
<applet class="AppletBorder" code="BorderLayoutDemo.class" width="500"  CODEBASE="../../../classes/" height="300"></applet></p>
<hr/>
<h2>BorderLayout with proper add() method</h2>
<p><strong>Program:</strong></p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class BorderLayoutAddDemo extends Applet
{
	Button b1, b2, b3;
	public void init()
	{
		BorderLayout bl = new BorderLayout();
		setLayout(bl);
		
		b1 = new Button(&quot;Button1&quot;);
		b2 = new Button(&quot;Button2&quot;);
		b3 = new Button(&quot;Button3&quot;);
		
		add(b1, BorderLayout.NORTH);
		add(b2, BorderLayout.WEST);
		add(b3);
	}	
}
/*
&lt;applet code=&quot;BorderLayoutAddDemo&quot; width=&quot;500&quot; height=&quot;500&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><br />
<applet class="AppletBorder" code="BorderLayoutAddDemo.class" width="500"  CODEBASE="../../../classes/" height="500"></applet></p>
<hr/>
<p>By default the center part will only be visible. If we do not add any component in any other part. CENTER part will occupy the complete area. That means, In case we have used NORTH, CENTER and WEST directions then other areas will not be created at all as shown in the applet above. To change the size occupied by any of the direction. we have to invoke a setPreferredSize() method on the component which we have added. </p>
<hr/>
<h2>Re-sizing a part of BorderLayout</h2>
<p><strong>Program:</strong></p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class BorderLayoutAddResizeDemo extends Applet
{
	Button b1, b2, b3;
	public void init()
	{
		BorderLayout bl = new BorderLayout();
		setLayout(bl);
		
		b1 = new Button(&quot;Button1&quot;);
		b2 = new Button(&quot;Button2&quot;);
		b3 = new Button(&quot;Button3&quot;);
		b1.setPreferredSize(new Dimension(500,250));
		add(b1, BorderLayout.NORTH);
		add(b2, BorderLayout.WEST);
		add(b3);
	}	
}
/*
&lt;applet code=&quot;BorderLayoutAddResizeDemo&quot; width=&quot;500&quot; height=&quot;500&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><br />
<applet class="AppletBorder" code="BorderLayoutAddResizeDemo.class" width="500"  CODEBASE="../../../classes/" height="500"></applet></p>
<hr/>
<h2>Complete BorderLayout</h2>
<p><strong>Program:</strong></p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class BorderLayoutCompleteDemo extends Applet
{
	Button b1, b2, b3;
	public void init()
	{
		BorderLayout bl = new BorderLayout();
		setLayout(bl);
		
		b1 = new Button(&quot;Button1&quot;);
		b2 = new Button(&quot;Button2&quot;);
		b3 = new Button(&quot;Button3&quot;);
		add(b1, BorderLayout.NORTH);
		add(b2, BorderLayout.WEST);
		add(b3);
		add(new Button(&quot;Button4&quot;),BorderLayout.SOUTH);
		add(new Button(&quot;Button5&quot;),BorderLayout.EAST);
	}	
}
/*
&lt;applet code=&quot;BorderLayoutCompleteDemo&quot; width=&quot;500&quot; height=&quot;500&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><br />
<applet class="AppletBorder" code="BorderLayoutCompleteDemo.class" width="500"  CODEBASE="../../../classes/" height="500"></applet></p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/layouts/borderlayout">BorderLayout</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ankit.co/tutorials/java-tutorials/layouts/borderlayout/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GridLayout</title>
		<link>http://ankit.co/tutorials/java-tutorials/layouts/gridlayout?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gridlayout</link>
		<comments>http://ankit.co/tutorials/java-tutorials/layouts/gridlayout#comments</comments>
		<pubDate>Sat, 12 Jan 2013 06:59:06 +0000</pubDate>
		<dc:creator><![CDATA[Ankit Virparia]]></dc:creator>
				<category><![CDATA[Layouts]]></category>
		<category><![CDATA[GridLayout]]></category>
		<category><![CDATA[Layout]]></category>

		<guid isPermaLink="false">http://ankit.co/?p=434</guid>
		<description><![CDATA[<p>java.awt.GridLayout is the Layout which divides component area into a Grid of specified rows and cols. GridLayout can be useful in case when we need equal sub parts of a component ares. It re sizes the components added in it. Component add sequence plays an important role when we have set GridLayout. To set any [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/layouts/gridlayout">GridLayout</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>java.awt.GridLayout is the Layout which divides component area into a Grid of specified rows and cols. GridLayout can be useful in case when we need equal sub parts of a component ares. It re sizes the components added in it. Component add sequence plays an important role when we have set GridLayout. To set any layout of any component the method which can be used is: <strong>componetObject.setLayout(layoutManagerObject);</strong></p>
<h2>GridLayout Constructors</h2>
<ol>
<li>
<h3>GridLayout()</h3>
<p>          This constructor creates one column for each component we add. Only 1 row will be created.
</li>
<li>
<h3>GridLayout(int rows, int cols)</h3>
<p>          This constructor creates specified number of rows and columns.
</li>
<li>
<h3>GridLayout(int rows, int cols, int hgap, int vgap) </h3>
<p>          This constructor creates specified number of rows and columns plus sets the given horizontal and vertical space between components.
</li>
</ol>
<hr/>
<p>As discussed in the above constructor summary, We have a constructor which takes rows and columns value as integers. Here the constrain/characteristic is: <strong>GridLayout is rigid about row creation. and It&#8217;s flexible in terms of column creation.</strong> For example, If we ask GridLayout to create 20 rows and 20 columns for us and we add only 3 components in Grid. In that case: It automatically understands our requirement and create 20 rows(Its for sure!) and 1 column only(Its Flexible!). Because 20 rows can accommodate our all components. In case we add 21 components, it will create 2 columns.  </p>
<h2>GridLayout with 2 rows and 2 columns</h2>
<p><strong>Program:</strong></p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class GridLayoutDemo extends Applet
{
	Button b1, b2, b3;
	public void init()
	{
		GridLayout gl = new GridLayout(2,2);
		setLayout(gl);
		
		b1 = new Button(&quot;Button1&quot;);
		b2 = new Button(&quot;Button2&quot;);
		b3 = new Button(&quot;Button3&quot;);
		
		add(b1);
		add(b2);
		add(b3);
	}	
}
/*
&lt;applet code=&quot;GridLayoutDemo&quot; width=&quot;500&quot; height=&quot;200&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><br />
<applet class="AppletBorder" code="GridLayoutDemo.class" width="500"  CODEBASE="../../../classes/" height="300"></applet></p>
<hr/>
<h2>GridLayout with 20 rows 20 columns</h2>
<p><strong>Program:</strong></p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class GridLayout20Demo extends Applet
{
	Button b1, b2, b3;
	public void init()
	{
		GridLayout gl = new GridLayout(20,20);
		setLayout(gl);
		
		b1 = new Button(&quot;Button1&quot;);
		b2 = new Button(&quot;Button2&quot;);
		b3 = new Button(&quot;Button3&quot;);
		
		add(b1);
		add(b2);
		add(b3);
	}	
}
/*
&lt;applet code=&quot;GridLayout20Demo&quot; width=&quot;500&quot; height=&quot;500&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><br />
<applet class="AppletBorder" code="GridLayout20Demo.class" width="500"  CODEBASE="../../../classes/" height="500"></applet></p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/layouts/gridlayout">GridLayout</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ankit.co/tutorials/java-tutorials/layouts/gridlayout/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FlowLayout</title>
		<link>http://ankit.co/tutorials/java-tutorials/layouts/flowlayout?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flowlayout</link>
		<comments>http://ankit.co/tutorials/java-tutorials/layouts/flowlayout#comments</comments>
		<pubDate>Sat, 12 Jan 2013 05:10:24 +0000</pubDate>
		<dc:creator><![CDATA[Ankit Virparia]]></dc:creator>
				<category><![CDATA[Layouts]]></category>
		<category><![CDATA[FlowLayout]]></category>
		<category><![CDATA[Layout]]></category>

		<guid isPermaLink="false">http://ankit.co/?p=429</guid>
		<description><![CDATA[<p>java.awt.FlowLayout is the default Layout of Applet, JApplet, Panel, JPanel. Characteristics of FlowLayout is to attach the components one after another in specified direction. Main advantage of using FlowLayout is that: It do not resize the component. It just allocate the space required by the component. to set any layout of any component the method [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/layouts/flowlayout">FlowLayout</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>java.awt.FlowLayout is the default Layout of Applet, JApplet, Panel, JPanel. Characteristics of FlowLayout is to attach the components one after another in specified direction. Main advantage of using FlowLayout is that: It do not resize the component. It just allocate the space required by the component. to set any layout of any component the method which can be used is: <strong>componetObject.setLayout(layoutManagerObject);</strong></p>
<h2>FlowLayout Constructors</h2>
<ol>
<li>
<h3>FlowLayout()</h3>
<p>          This constructs is used to create a center aligned and a default 5-unit horizontal and vertical gap based FlowLayout object.
</li>
<li>
<h3>FlowLayout(int align)</h3>
<p>          This constructs is used to create the specified alignment and a default 5-unit horizontal and vertical gap based FlowLayout object.
</li>
<li>
<h3>FlowLayout(int align, int hgap, int vgap)</h3>
<p>          This constructor is used to create a new flow layout with the indicated alignment and the indicated horizontal and vertical gaps.
</li>
</ol>
<hr/>
<p>As discussed in the above constructor summary, We have a constructor which takes alignment value as integer. Here the problem is: We can not remember exact value for each alignment. For this , Java provides one easy option in which we have to pass a <strong>static</strong> VARIABLE as a argument. Again that static value will get from the same class we are using. For example, Here in our case we would like to pass an integer value which creates a LEFT aligned layout for us. For that we can use a public final and static int variable of FlowLayout class which is named as LEFT. And as you know: To access a static variable/method we don&#8217;t need object. That can be done by simply writing class name. i.e. <strong>FlowLayout.LEFT</strong>. So the syntax to change the layout of our base class will be <strong>this.setLayout(new FlowLayout());</strong> which will create a CENTER aligned FlowLayout. For left Alignment we can use <strong>this.setLayout(new FlowLayout(FlowLayout.LEFT));</strong></p>
<h2>FlowLayout Alignments</h2>
<ol>
<li>
<h3>CENTER</h3>
<p>          This creates a center aligned FlowLayout. Components will be aligned to center.
</li>
<li>
<h3>LEFT</h3>
<p>          This creates a left aligned FlowLayout. Components will be aligned to left.
</li>
<li>
<h3>RIGHT</h3>
<p>          This creates a right aligned FlowLayout. Components will be aligned to right.
</li>
<li>
<h3>LEADING</h3>
<p>          This aligns all the components to the LEADING edge of parent/container component. In case the parent component is Right aligned and we use LEADING, the alignment which will be generated will be Right.
</li>
<li>
<h3>TRAILING</h3>
<p>          This aligns all the components to the TRAILING edge of parent/container component. In case the parent component is Right aligned and we use TRAILING, the alignment which will be generated will be LEFT.
</li>
</ol>
<hr/>
<h2>FlowLayout with Center Alignment</h2>
<p><strong>Program:</strong></p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class FlowLayoutDemo extends Applet
{
	Button b1, b2, b3;
	public void init()
	{
		FlowLayout fl = new FlowLayout();
		setLayout(fl);
		
		b1 = new Button(&quot;Button1&quot;);
		b2 = new Button(&quot;Button2&quot;);
		b3 = new Button(&quot;Button3&quot;);
		
		add(b1);
		add(b2);
		add(b3);
	}	
}
/*
&lt;applet code=&quot;FlowLayoutDemo&quot; width=&quot;500&quot; height=&quot;200&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><br />
<applet class="AppletBorder" code="FlowLayoutDemo.class" width="500"  CODEBASE="../../../classes/" height="200"></applet></p>
<hr/>
<h2>FlowLayout with LEFT Alignment</h2>
<p><strong>Program:</strong></p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class FlowLayoutLeftDemo extends Applet
{
	Button b1, b2, b3;
	public void init()
	{
		FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
		setLayout(fl);
		
		b1 = new Button(&quot;Button1&quot;);
		b2 = new Button(&quot;Button2&quot;);
		b3 = new Button(&quot;Button3&quot;);
		
		add(b1);
		add(b2);
		add(b3);
	}	
}
/*
&lt;applet code=&quot;FlowLayoutLeftDemo&quot; width=&quot;500&quot; height=&quot;200&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><br />
<applet class="AppletBorder" code="FlowLayoutLeftDemo.class" width="500"  CODEBASE="../../../classes/" height="200"></applet></p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/layouts/flowlayout">FlowLayout</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ankit.co/tutorials/java-tutorials/layouts/flowlayout/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
