{"id":2766,"date":"2017-12-05T08:01:46","date_gmt":"2017-12-05T08:01:46","guid":{"rendered":"http:\/\/webartdevelopers.com\/?p=2766"},"modified":"2018-06-27T15:11:42","modified_gmt":"2018-06-27T15:11:42","slug":"how-to-create-a-card-layout-frame-in-core-java","status":"publish","type":"post","link":"https:\/\/webartdevelopers.com\/blog\/how-to-create-a-card-layout-frame-in-core-java\/","title":{"rendered":"How to create a Card Layout Frame in Core Java"},"content":{"rendered":"<p>In this tutorial how to create a Card Layout Frame in Core Java is shown.<\/p>\n<p>Code:<\/p>\n<p>CardLayoutExample.java<\/p>\n<p>import java.awt.*;<br \/>\nimport java.awt.event.*;<\/p>\n<p>import javax.swing.*;<\/p>\n<p>public class CardLayoutExample extends JFrame implements ActionListener<br \/>\n{<br \/>\nCardLayout card;<br \/>\nJButton b1,b2,b3;<br \/>\nContainer c;<\/p>\n<p>CardLayoutExample()<br \/>\n{<br \/>\nc = getContentPane();<br \/>\ncard = new CardLayout(40,30);<\/p>\n<p>c.setLayout(card);<\/p>\n<p>b1 = new JButton(&#8220;Button1&#8221;);<br \/>\nb2 = new JButton(&#8220;Button2&#8221;);<br \/>\nb3 = new JButton(&#8220;Button3&#8221;);<\/p>\n<p>b1.addActionListener(this);<br \/>\nb2.addActionListener(this);<br \/>\nb3.addActionListener(this);<\/p>\n<p>c.add(&#8220;a&#8221;,b1);<br \/>\nc.add(&#8220;b&#8221;,b2);<br \/>\nc.add(&#8220;c&#8221;,b3);<br \/>\n}<\/p>\n<p>public void actionPerformed(ActionEvent e)<br \/>\n{<br \/>\ncard.next(c);<br \/>\n}<\/p>\n<p>public static void main(String[] args)<br \/>\n{<br \/>\nCardLayoutExample cl = new CardLayoutExample();<br \/>\ncl.setSize(400,400);<br \/>\ncl.setVisible(true);<br \/>\ncl.setDefaultCloseOperation(EXIT_ON_CLOSE);<br \/>\n}<br \/>\n}<\/p>\n<p><a href=\"https:\/\/youtu.be\/aUwfiGQvFfc\">https:\/\/youtu.be\/aUwfiGQvFfc<\/a><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"In this tutorial how to create a Card Layout Frame in Core Java is shown. Code: CardLayoutExample.java import java.awt.*; import java.awt.event.*; import javax.swing.*; public class CardLayoutExample extends JFrame implements ActionListener { CardLayout card; JButton b1,b2,b3; Container c; CardLayoutExample() { c = getContentPane(); card = new CardLayout(40,30); c.setLayout(card); b1 = new JButton(&#8220;Button1&#8221;); b2 = new JButton(&#8220;Button2&#8221;); b3 = new JButton(&#8220;Button3&#8221;); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); c.add(&#8220;a&#8221;,b1); c.add(&#8220;b&#8221;,b2); c.add(&#8220;c&#8221;,b3); } public void actionPerformed(ActionEvent e) { card.next(c); } public static void main(String args) { CardLayoutExample cl = new CardLayoutExample(); cl.setSize(400,400); cl.setVisible(true); cl.setDefaultCloseOperation(EXIT_ON_CLOSE); } }<!-- AddThis Advanced Settings generic via filter on get_the_excerpt -->","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[156],"tags":[230,157,227],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2766"}],"collection":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/comments?post=2766"}],"version-history":[{"count":3,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2766\/revisions"}],"predecessor-version":[{"id":3170,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2766\/revisions\/3170"}],"wp:attachment":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/media?parent=2766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/categories?post=2766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/tags?post=2766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}