자바 this에 관해 질문드립니다
package lib2;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
class MyFrame2 extends JFrame{
public MyFrame2() {
super("Listener입니다.");
setDefaultCloseOperation(JFrame.EXITONCLOSE);
Container conpane=getContentPane();
conpane.setBackground(Color.ORANGE);
conpane.setLayout(new FlowLayout());
JButton bb=new JButton("Hello");
bb.addActionListener(new MyActionLis());
setSize(300,300);
setVisible(true);//프레임보여줌
conpane.add(new JButton("Click"));
conpane.add(new JButton("OK"));
conpane.add(new JButton("Cancel"));
conpane.add(bb);
}
private class MyActionLis implements ActionListener{
public void actionPerformed(ActionEvent e) {
JButton b=(JButton)e.getSource();
if(b.getText()=="1")
b.setText("3");
else
b.setText("1");
MyFrame2.this.setTitle(b.getText());
}
}
}
public class myFrame {
public static void main(String[] args) {
MyFrame2 frame=new MyFrame2();
;
}
}
이부분에서 this를 굳이 써야하는 이유가 있을까요..??
MyFrame2.setTitle(b.getText())와 다른점을 도저히 모르겠습니다