<?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; CardLayout</title>
	<atom:link href="http://ankit.co/tag/cardlayout/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>
	</channel>
</rss>
