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

📄 cldemo.java

📁 java 完全探索的随书源码
💻 JAVA
字号:
// CLDemo.java

import java.awt.*;
import java.awt.event.*;

class CLDemo extends Frame implements ActionListener, ItemListener
{
   final static int NOGAPS = 0;
   final static int GAPS = 1;

   CLDemo (String title, int gapsOption)
   {
      super (title);

      if (gapsOption == GAPS)
          setLayout (new CardLayout (10, 10));
      else
          setLayout (new CardLayout ());

      Panel p1 = new Panel ();
      Button b = new Button ("Press Me");
      b.addActionListener (this);
      p1.add (b);
      add (p1, "First");

      Panel p2 = new Panel ();
      Checkbox cb = new Checkbox ("Check or Uncheck Me");
      cb.addItemListener (this);
      p2.add (cb, "Second");
      add (p2, "Second");

      setSize (200, 100);
      setVisible (true);
   }

   public void actionPerformed (ActionEvent e)
   {
      // Switch to the other card.

      ((CardLayout) getLayout ()).next (this);
   }

   public void itemStateChanged (ItemEvent e)
   {
      // Switch to the other card.

      ((CardLayout) getLayout ()).next (this); 
   }

   public static void main (String [] args)
   {
      int option = NOGAPS;

      for (int i = 0; i < args.length; i++)
           if (args [i].equalsIgnoreCase ("GAPS"))
               option = GAPS;
           else
           if (args [i].equalsIgnoreCase ("NOGAPS"))
               option = NOGAPS;

      new CLDemo ("CardLayout Demo", option);
   }
}

⌨️ 快捷键说明

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