Login    New User    Forgot Password    Help      

Card Layout

Java Tutorials

Example

// card layout
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="control13" width=250 height=300>

</applet>
*/

public class control13 extends Applet implements ActionListener,MouseListener
{

Checkbox oracle,access,java,visualbasic;
Panel p;
CardLayout c;
Button database,lanGuage;

public void init()

{
database=new Button ("Database");
lanGuage=new Button ("Language");
add(database);
add(lanGuage);

c=new CardLayout();
p=new Panel();
p.setLayout(c);

oracle=new Checkbox("Oracle", null,true);
access=new Checkbox("Access");
java=new Checkbox("Java");
visualbasic=new Checkbox("visual basic");

Panel d=new Panel();
d.add(oracle);
d.add(access);

Panel l=new Panel();
l.add(java);
l.add(visualbasic);

p.add(d,"Database");
p.add(l,"Language");
add(p);

database.addActionListener(this);
lanGuage.addActionListener(this);

addMouseListener(this);

}
public void mousePressed(MouseEvent me)
{
c.next(p);
}

public void mouseEntered(MouseEvent me)
{
}
public void mouseClicked(MouseEvent me)
{
}

public void mouseExited(MouseEvent me)
{
}
public void mouseReleased(MouseEvent me)
{
}

public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==database)
{
c.show(p,"Data Base");
}
else
{
c.show(p,"Language");
}
}
}

Output

Output in applet

Java Tutorials