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);
}
}
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