/*开通自己的博客,菜鸟正式开始了自己的奋斗生涯。最近正在自学java,遇到了很多困难不过菜鸟坚信可以克服它。我也相信我们的团队可以在这次小的比赛中逐渐壮大。*/
//小试手
import java.awt.*;
import java.awt.event.*;
class WinCard extends Frame implements ActionListener
{
CardLayout mycard;
Button buttonFirst,buttonNext,buttonLast;
Panel pCenter;
WinCard()
{
mycard=new CardLayout();
pCenter=new Panel();
pCenter.setLayout(mycard);
buttonFirst=new Button("first");
buttonNext=new Button("next");
buttonLast=new Button("last");
for (int i=0;i<=20 ;i++ )
{
pCenter.add("i am"+i,new Button("我是第"+i+"个按钮 "));
}
buttonFirst.addActionListener(this);
buttonNext.addActionListener(this);
buttonLast.addActionListener(this);
Panel pSouth=new Panel();
pSouth.add(buttonFirst);
pSouth.add(buttonNext);
pSouth.add(buttonLast);
add(pCenter,BorderLayout.CENTER);
add(pSouth,BorderLayout.SOUTH);
setBounds(10,10,500,490);
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==buttonFirst)
{mycard.first(pCenter);
}
else if (e.getSource()==buttonNext)
{mycard.next(pCenter);
}
else if (e.getSource()==buttonLast)
{mycard.last(pCenter);
}
}
}
public class Example7_14
{
public static void main(String args[])
{
new WinCard();
}
}