package com.company;

import javax.swing.*;
import java.awt.*;

public class Main extends JFrame {
    Main(){
        setBounds(100,100,300,200);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        Container c=getContentPane();
        c.setLayout(new FlowLayout(FlowLayout.RIGHT,20,20));//给容器设置流布局
        /*
        FlowLayout.CENTER-----中心对齐;
        FlowLayout.LEADING-----顶对齐;
        FlowLayout.LEFT--------左对齐;
        FlowLayout.RIGHT-------右对齐;
        FlowLayout.TRAILING----排序对齐;
         */
        for (int i=1;i<10;i++){
            c.add(new JButton("按钮"+i));
        }
        setVisible(true);

 

    }

    public static void main(String[] args) {
         new  Main();
	// write your code here
    }
}

 流布局, FlowLayout(FlowLayout.TRAILING)

 

流布局, FlowLayout(FlowLayout.TRAILING)

 

相关文章:

  • 2021-06-23
  • 2021-08-01
  • 2022-03-01
  • 2021-04-30
  • 2021-12-07
  • 2022-12-23
  • 2021-12-13
  • 2021-11-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2021-05-21
  • 2021-04-30
  • 2022-01-04
相关资源
相似解决方案