fldemo.java

来自「java 完全探索的随书源码」· Java 代码 · 共 50 行

JAVA
50
字号
// FLDemo.java

import java.awt.*;

class FLDemo extends Frame
{
   final static int NOGAPS = 0;
   final static int GAPS = 1;

   FLDemo (String title, int gapsOption, int alignOption)
   {
      super (title);

      if (gapsOption == GAPS)
          setLayout (new FlowLayout (alignOption));
      else
          setLayout (new FlowLayout (alignOption, 0, 0));

      for (int i = 0; i < 10; i++)
           add (new Button ("Button " + i));

      setSize (250, 250);
      setVisible (true);
   }

   public static void main (String [] args)
   {
      int option1 = NOGAPS;
      int option2 = FlowLayout.LEFT;

      for (int i = 0; i < args.length; i++)
           if (args [i].equalsIgnoreCase ("LEFT"))
               option2 = FlowLayout.LEFT;
           else
           if (args [i].equalsIgnoreCase ("RIGHT"))
               option2 = FlowLayout.RIGHT;
           else
           if (args [i].equalsIgnoreCase ("CENTER"))
               option2 = FlowLayout.CENTER;
           else
           if (args [i].equalsIgnoreCase ("GAPS"))
               option1 = GAPS;
           else
           if (args [i].equalsIgnoreCase ("NOGAPS"))
               option1 = NOGAPS;

      new FLDemo ("FlowLayout Demo", option1, option2);
   }
}

⌨️ 快捷键说明

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