Java 9일차 ActionListener 테스트2 (내부무명이벤트)

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;

public class EventTest2 extends JFrame
{
JTextArea ta;
JButton button;

public EventTest2()
{
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(400, 300);
this.setVisible(true);

ta = new JTextArea();

button = new JButton("클릭");
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ta.append("내부 무명 클래스"+'\n');
}
});

add(ta);
add("North", button);
}

public static void main(String[] args)
{
new EventTest2();
}
}


댓글 없음: