내 응용 프로그램에 문제가 있습니다. AWT 구성 요소를 사용하여 JButton을 만들려고합니다. 주요 문제는 예외가 있습니다 : QButton.QButton.addActionListener (QButton.java:83). //this.addActionListener 행을 주석 처리하면 모든 것이 정상입니다. 나의 목적은 내가 UI 것들에 익숙하지 해요,하지만 프로그램 자체를 호출 할 메서드를 호출하려고하기 때문에 당신이 StackOverflowException
얻는 이유입니다 패널addActionListener 메서드에 대한 Stackoverflow 예외
public class QButton extends Panel implements MouseListener,ActionListener{
public Label text;
ImagePanel image;
ActionListener listener;
public QButton(String text){
Label l = new Label(text);
this.add(l);
this.text=l;
this.setLayout(new GridBagLayout());
this.setBackground(Color.gray);
TextButtonActions ac1=new TextButtonActions(this);
this.addMouseListener(ac1);
this.text.addMouseListener(ac1);
}
public QButton(ImagePanel img){
this.setLayout(new GridLayout());
this.image=img;
this.add(image);
PictureButtonActions ac2=new PictureButtonActions(this);
this.image.addMouseListener(ac2);
}
public QButton(String text, ImagePanel img){
this.setBackground(Color.gray);
this.setLayout(new GridLayout());
Label l = new Label(text);
this.add(l);
this.text=l;
this.image=img;
this.add(image);
TAndPButtonActions ac3=new TAndPButtonActions(this);
this.image.addMouseListener(ac3);
this.text.addMouseListener(ac3);
}
public void setText(String txt)
{
this.text.setText(txt);
}
public String getText()
{
return(text.getText());
}
public void setImage(ImagePanel i)
{
this.remove(image);
this.image=i;
this.add(i);
//System.out.println("setImage");
this.validate();
}
public ImagePanel getImage()
{
return(image);
}
void addActionListener(ActionListener listener)
{
this.listener=listener;
this.addActionListener(listener);
}
}
또 하나의 stackoverflow 문제가 stackoverflow! – Gautam
당신은 무엇을 기대합니까? 'this.addActionListener (listener);'무조건 자체적으로 – artistoex