Thursday, 7 May 2015

CARD LAYOUT PROGRAM IN JAVA

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/**
<APPLET CODE=cardlayout.class  WIDTH=200  HEIGHT=200>
</APPLET>
*/

public class cardlayout extends Applet implements ActionListener
{
Checkbox win98,winnt,solaris,mac;
Panel oscards.winpan,otherpan;
CardLayout card;
Button win,other;

public void init()
{
win=new Button(“windows”);
other=new Button(“others”);

add(win);
add(other);

card=newCardLayot(10,10);
oscards=new Panel();
oscards.SetLayout(card);

win98=new Checkbox(“windows 98”);
winnt=new Checkbox(“windowsnt”);
solaris=new Checkbox(“solaris”);
mac=new Checkbox(“macos”);

winpan=new Panel();
winpan.add(win98);
winpan.add(winnt);

otherpan=new Panel();
otherpan=add(solaris);
otherpan.add(mac);
oscards.add(winpan,”windows”);
oscards.add(otherpan,”other”);
add(oscards);
win.addActionListener(this);
other.addActionListener(this);
}

public void actionPerformed(ActionEvent e)
{
if(e.getSource()==win)
{
card.show(oscards,”windows”);
}
else
{
card.show(oscards,”other”);
}
}

}


No comments:

Post a Comment