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

📄 9.5-showgridlayout.java

📁 介绍有关java的资料 课件 相当一本书籍 里面都是很基础的知识
💻 JAVA
字号:
// ShowGridLayout.java: Demonstrate using GridLayout
import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.GridLayout;
import java.awt.Container;

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

    // Set GridLayout, 4 rows, 3 columns, and gaps 5 between
    // components horizontally and vertically
    container.setLayout(new GridLayout(4, 3, 35, 5));

    // 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)
  {
    ShowGridLayout frame = new ShowGridLayout();
    frame.setTitle("Show GridLayout");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200, 200);
    frame.setVisible(true);
  }
}

⌨️ 快捷键说明

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