import java.awt.*;
import java.awt.event.*;
class Test{
public static void main(String [] args){
Frame f=new Frame("變換");
CardLayout c1=new CardLayout();
f.setLayout(c1);
Button b []=new Button[4];
for(int i=0;i<4;i++){
b[i]=new Button("第"+i+"頁(yè)");
f.add(b[i],"page"+i);
}
b[0].setBackground(Color.red);
b[1].setBackground(Color.blue);
b[2].setBackground(Color.cyan);
b[3].setBackground(Color.green);
f.pack();
f.setVisible(true);
while(true){
try{
Thread.sleep(50);
}
catch (InterruptedException e){
e.printStackTrace();
}
c1.next(f);
}
}
}
posted on 2009-09-24 11:08
鵬凌 閱讀(970)
評(píng)論(0) 編輯 收藏 所屬分類:
Java --j2ee