Java 9일차 ActionListener 테스트

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

public class EventTest extends JFrame implements ActionListener
{
JTextArea ta;
JButton button;

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

ta = new JTextArea();

button = new JButton("클릭");
button.addActionListener(this);

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

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

public void actionPerformed(ActionEvent e)
{
//ta.setText("버튼 클릭");
ta.append("한번 더"+'\n');
}
}


댓글 없음: