/*
 * Copyright (c) 2024. Elex. All Rights Reesrved.
 * https://www.elex-project.com/
 */

package com.elex_project.examples.layouts;

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

public class FlowLayoutExample extends JPanel {

	FlowLayoutExample() {
		super(new FlowLayout());

		final JButton button1 = new JButton("Button 1");
		final JButton button2 = new JButton("Button 2");
		final JButton button3 = new JButton("Button 3");
		final JButton button4 = new JButton("Button 4");
		final JButton button5 = new JButton("Button 5");

		add(button1);
		add(button2);
		add(button3);
		add(button4);
		add(button5);

		FlowLayout layout = (FlowLayout) this.getLayout();
		layout.setAlignment(FlowLayout.TRAILING);
	}

	public static void main(String... args) {

		// 프레임을 생성한다.
		final JFrame jFrame = new JFrame();
		jFrame.setTitle("Example");
		jFrame.setSize(800, 600);
		jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jFrame.setContentPane(new FlowLayoutExample());

		// 이벤트 디스패치 스레드에서 프레임을 표시한다.
		SwingUtilities.invokeLater(() -> {
			jFrame.setVisible(true);
		});

	}
}
