Witshaper is the Professional (Computing Skills, English Learning and Soft Skills) Skill Development Training Center. We provide Professional IT Courses and Soft Skill Training in Dehradun to Students, Employees and organization. Who wish to pursue a career in IT Technology. Witshaper is led by a motivated team of IT experts and Soft Skill Professionals. We provide high quality trainings. Our Emphasis is on giving the practical knowledge to the students, so that they will get to know in depth and never forget what they opt, we provide to the students real learning environment. Witshaper prepares students and professionals to be the part of this growing industry. Be a part of Witshaper and get your dreams successful

Sunday 15 May 2016

applet program: Implementing Card layout and panel

import java.awt.*;
import java.awt.event.*;
public class Card1 extends Frame implements ActionListener
{
CardLayout cl;
Panel p1,p2,p3,p4,p5;
Button b1,b2,b3,b4,b5,b6;
Card1()
{
b1=new Button("Next");
b2=new Button("Previous");
b3=new Button("Next");
b4=new Button("Previous");
b5=new Button("Next");
b6=new Button("End");

p1=new Panel();
p1.setLayout(new FlowLayout());
p1.setBackground(Color.yellow);
p1.add(b1);

p2=new Panel();
p2.setLayout(new FlowLayout());
p2.setBackground(Color.pink);
p2.add(b2);
p2.add(b3);

p3=new Panel();
p3.setLayout(new FlowLayout());
p3.setBackground(Color.green);
p3.add(b4);
p3.add(b5);

p4=new Panel();
p4.setLayout(new FlowLayout());
p4.setBackground(Color.cyan);
p4.add(b6);

p5=new Panel();
cl=new CardLayout();
p5.setLayout(cl);
p5.add(p1,"First");
p5.add(p2,"Second");
p5.add(p3,"Third");
p5.add(p4,"Fourth");

add(p5);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
cl.next(p5);
if(ae.getSource()==b2)
cl.previous(p5);
if(ae.getSource()==b3)
cl.next(p5);
if(ae.getSource()==b4)
cl.previous(p5);
if(ae.getSource()==b5)
cl.next(p5);
if(ae.getSource()==b6)
cl.first(p5);

}
public static void main(String ar[])
{
Card1 c1=new Card1();
c1.setSize(400,200);
c1.setVisible(true);
}
}

No comments:

Post a Comment