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

📄 showflowlayout.java

📁 此源码为机械工业出版社出版的《Java语言程序设计》第三版所配套的书中所有源代码。
💻 JAVA
字号:
// ShowFlowLayout.java: Demonstrate using FlowLayout
import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.Container;
import java.awt.FlowLayout;

public class ShowFlowLayout extends JFrame
{
  // Default constructor
  public ShowFlowLayout()
  {
    // Get the content pane of the frame
    Container container = getContentPane();

    // Set FlowLayout, aligned left with horizontal gap 10
    // and vertical gap 20 between components
    container.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));

    // Add buttons to the frame
    for (int i=1; i<=10; i++)
      container.add(new JButton("Component " + i));
  }

  // Main method
  public static void main(String[] args)
  {
    ShowFlowLayout frame = new ShowFlowLayout();
    frame.setTitle("Show FlowLayout");
    // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200, 200);
    frame.setVisible(true);
  }
}

⌨️ 快捷键说明

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