流布局, FlowLayout(FlowLayout.TRAILING)
阿新 • • 發佈:2018-12-08
etc http opera void etl clas idt lead imp
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)