扑克牌般叠显的感觉,用起来不错。
在QT里,没有遇过。像CardLayout,是不是java特有的?那么在Android里呢?
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;class WinCard extends Frame implements ActionListener {
private static final long serialVersionUID = 4317426513460347061L;
CardLayout mycard;
Button buttonFirst;
Button buttonLast;
Button buttonNext;
Panel pCenter;
WinCard() {
mycard = new CardLayout();
pCenter = new Panel();
pCenter.setLayout(mycard);
buttonFirst = new Button("first");
buttonLast = new Button("last");
buttonNext = new Button("next");
for (int i=1; i<=20; i++) {
pCenter.add("I am" + i, new Button("我是第 " + i + " 个按钮"));
}
buttonFirst.addActionListener(this);
buttonLast.addActionListener(this);
buttonNext.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, 200, 190);
setVisible(true);
validate();
} @Override
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_b {
    public static void main(String args[]) {
     new WinCard();
    }
}