📄 testcardlayout.java
字号:
package test.gui;
import javax.swing.*;
import java.awt.*;
public class TestCardLayout {
public static void main(String[] args){
JFrame frame = new JFrame();
CardLayout cl = new CardLayout();
frame.setLayout(cl);
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3= new JPanel();
p1.setBackground(Color.red);
p2.setBackground(Color.BLUE);
p3.setBackground(Color.yellow);
frame.add(p1, "p1");
frame.add(p2, "p2");
frame.add(p3, "p3");
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
for(int i=0; i<7; i++){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cl.next(frame.getContentPane());
}
cl.show(frame.getContentPane(), "p2");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -