자바 액션리스너 사용 4가지 방법 (4)
package 액션리스너_4가지_유형;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
@SuppressWarnings("serial")
class MyFrame4 extends JFrame{
JPanel panel;
JButton button;
MyFrame4(){
setTitle("이벤트 예제");
setSize(300, 200);
panel = new JPanel();
button = new JButton("버튼을 누르시오");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
if(e.getSource() == button){
button.setText("이벤트 발생");
}
}
});
panel.add(button);
add(panel);
setVisible(true);
}
}
public class Lt4 {
public static void main(String[] args) {
new MyFrame4();
}
}
Author And Source
이 문제에 관하여(자바 액션리스너 사용 4가지 방법 (4)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@ksy1376/자바-액션리스너-사용-4가지-방법-4저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)