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

package com.elex_project.examples.components.button;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

public class ActionExample extends JPanel {
	private static class Action1 extends AbstractAction {
		Action1() {
			super();
			putValue(NAME, "Button 1");
			putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK));
		}

		@Override
		public void actionPerformed(ActionEvent actionEvent) {
			System.out.println("Hello");
		}
	}

	public ActionExample() {
		super(new FlowLayout());


		final JButton button1 = new JButton(new Action1());


		// 레이아웃에 추가
		add(button1);

	}

	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 ActionExample());

		SwingUtilities.invokeLater(() -> {
			jFrame.setVisible(true);
		});


	}

}
