⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testcardlayout.java

📁 针对越来越多的用户喜欢JAVA
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
public class TestCardLayout 
{
  Panel p1, p2, p3, p4, p5; 
  Label l1, l2, l3, l4, l5; 
  CardLayout myCard;
  Frame f; 
  public static void main (String args[])
  { 
   TestCardLayout ct = new TestCardLayout();
   ct.init(); 
  }
  public void init()
  {
    f = new Frame ("CardLayout");
    myCard = new CardLayout();
    f.setLayout(myCard); 
    p1 = new Panel(); 
    p2 = new Panel();
    p3 = new Panel(); 
    p4 = new Panel(); 
    p5 = new Panel();
    l1 = new Label("This is the first Panel"); 
    p1.setBackground(Color.yellow); 
    p1.add(l1);
    l2 = new Label("This is the second Panel"); 
    p2.setBackground(Color.green);
    p2.add(l2); 
    l3 = new Label("This is the third Panel"); 
    p3.setBackground(Color.magenta); 
    p3.add(l3); 
    l4 = new Label("This is the fourth Panel"); 
    p4.setBackground(Color.white); 
    p4.add(l4);
    l5 = new Label("This is the fifth Panel"); 
    p5.setBackground(Color.cyan);
    p5.add(l5);
    f.add(p1, "First");
    f.add(p2, "Second"); 
    f.add(p3, "Third");
    f.add(p4, "Fourth");
    f.add(p5, "Fifth");
    myCard.show(f, "First");
    f.setSize (200, 200);
    f.setVisible(true); 
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -