windowflow.java

来自「在JAVA中」· Java 代码 · 共 27 行

JAVA
27
字号
import java.awt.*;
import javax.swing.*;
class WindowFlow extends JFrame 
{  
    WindowFlow(String s) 
    { 
      super(s);
      Container  contenetPane=this.getContentPane();
      FlowLayout flow=new FlowLayout();
      flow.setAlignment(FlowLayout.LEFT);
      flow.setHgap(2);
      flow.setVgap(8);
      contenetPane.setLayout(flow);
      for(int i=1;i<=10;i++) 
         { 
           contenetPane.add(new JButton("i am "+i));
         }
      setBounds(100,100,150,120);
      setSize(400,200);
      setVisible(true);
      setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
    public static void main(String args[])
    { 
       WindowFlow win=new WindowFlow("FlowLayout布局窗口");
    }
}

⌨️ 快捷键说明

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