类名.this

来源:互联网 发布:你见过最恐怖的事 知乎 编辑:程序博客网 时间:2024/06/02 05:33

1.当在内部类中 使用this 表示内部类的对象, 为了访问外部层类的对象,可以使用 外层类.this

  eg:  

     

class QZZW extends JFrame {   //验证码验证类 10位验证码
private JTextField jt = new JTextField();
private JButton jb    = new JButton();
private String password;
public QZZW(){
this.password = Connect.getControlInfo();
Container container = getContentPane();
container.setLayout(new GridLayout(1, 3));
JLabel jl = new JLabel("PASSWORD:");             //标签属性设置
jl.setHorizontalAlignment(SwingConstants.CENTER);
jl.setSize(50, 10); 
jb.setText("OK");
jb.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String jtcontent = jt.getText();
if(password == "false"){
  new MyDialog(QZZW.this, "YOUR NET IS FUCK").setVisible(true);
}
   if(jtcontent.length() == 10 && password.indexOf(jtcontent) > -1){
UiLu.jfmain.setVisible(true);
setUnval();
}
}
});
container.add(jl);
container.add(jt);                        
container.add(jb);
this.setSize(400,50);
this.setTitle("Input Your PassWord");
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.setVisible(true);
}
public void setUnval(){
this.setVisible(false);
}
}

0 0
原创粉丝点击