자바 this 질문드립니다
로와
public class simplegui3c implements actionlistener{
jframe frame;
public static void main(string[] args){
simplegui3c gui = new simplegui3c();
gui.go();
}
public void go(){
frame = new jframe();
frame.setdefaultcloseoperation(jframe.exit_on_close);
jbutton button = new jbutton(change colors);
button.addactionlistener(this);
mydrawpanel drawpanel = new mydrawpanel();
frame.getcontentpane().add(borderlayout.south,button);
frame.getcontentpane().add(borderlayout.center,drawpanel);
frame.setsize(300,300);
frame.setvisible(true);
}
public void actionperformed(actionevent event){
frame.repaint();
}
}
class mydrawpanel extends jpanel{
public void paintcomponent(graphics g){
g.fillrect(0,0,this.getwidth(),this.getheight());
int red = (int)(math.random() * 255);
int green = (int)(math.random() * 255);
int blue = (int)(math.random() * 255);
color randomcolor = new color(red,green,blue);
g.setcolor(randomcolor);
g.filloval(70,70,100,100);
}
}
다름이 아니라 리스너에 적힌 this라는 부분입니다. 저부분이 어떻걸 의미하는지 잘모르겠습니다 . 제생각엔
그다음에 나오는 public void actionperformed(actionevent event) 이 생성자부분에 영향을 받는거 같은데..아닌지
궁금합니다. 너무 초보적인 질문이라서 죄송합니다.