コンストラクタ | 説明 | 引数 | 引数説明 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
FlowLayout() | FlowLayout を作成 配置は中央、 水平&垂直方向間隔は 5で作成される |
- | - | ||||||||
FlowLayout(int align) | 指定された配置で FlowLayout を作成 水平&垂直方向間隔は 5で作成される |
align |
コンポーネントの配置方法
|
||||||||
FlowLayout(int align, int hgap, int vgap) | 指定された配置で隙間を空けた FlowLayout を作成 |
align | コンポーネントの配置方法 FlowLayout(int align)を参照 |
||||||||
hgap | 水平方向間隔 | ||||||||||
vgap | 垂直方向間隔 |
import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; /** * LayoutManager サンプル04 * ・FlowLayout * ・左詰、上下の隙間あり * * @author みっちー */ public class LayoutManager04 extends JFrame { /** * 開始メソッド * * @param args パラメータ */ public static void main(String[] args){ LayoutManager04 frame = new LayoutManager04(); // 閉じるボタンをクリックされた場合の動作を設定 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // ウインドウのタイトルを設定 frame.setTitle("LayoutManager サンプル04[FlowLayout]"); // フレームの X座標、Y座標、幅、高さを設定 frame.setBounds(100, 200, 480, 200); // フレームを表示(これをしないと透明のフレームが立ち上がってしまう) frame.setVisible(true); } /** * コンストラクタ */ public LayoutManager04() { // ベースとなるパネルを[FlowLayout]として作成 // 左詰、上下の隙間ありで作成 JPanel panelBase = new JPanel(); panelBase.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 10)); // ボタンを作成 JButton button1 = new JButton("AAAAA"); JButton button2 = new JButton("BBBBBBBB"); JButton button3 = new JButton("CCCCCCCCCC"); JButton button4 = new JButton("DDD"); JButton button5 = new JButton("EEEEE"); // パネルにボタンを配置 panelBase.add(button1); panelBase.add(button2); panelBase.add(button3); panelBase.add(button4); panelBase.add(button5); // ベースパネルを追加 getContentPane().add(panelBase, BorderLayout.CENTER); } }
2016/05/13 Windows 8.1 + Java 7 環境で全体を見直し 2007/12/07 新規作成