자바 고수님 질문좀 할께요
송아리
여기 소스요..
package library;
import javax.swing.JFrame;
public class Library extends JFrame{
public static void main(String[] args) {
Library lib=new Library();
lib.Prameset();
}
public void Prameset(){
Form frm=new Form();
setTitle(도서 관리 프로그램);
setSize(500, 800);
setResizable(false);
add(frm);
setVisible(true);
show();
}
}
----------------------------------------------------------
package library;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
public class Form extends JPanel implements ActionListener{
private JButton btn[];
private String str[]={확인,취소};
public void form(){
for(int i=0; i2; i++){
btn[i]=new JButton();
btn[i].setText(str[i]);
add(btn[i]);
}
}
public void actionPerformed(ActionEvent event) {
if(event.getActionCommand().equals(btn[0].getText())){
System.out.println(str[0]);
}else{
System.out.println(str[1]);
}
}
}여기서 버튼의 적용이 안되는데요 왜 그런건가요?
그리고 어떻게 적용시켜야 하나요?