Java" .addActionListener(this)" [英] Java ".addActionListener(this)"

查看:117
本文介绍了Java" .addActionListener(this)"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我添加一个动作侦听器,那么我总是在括号之间使用this。但是这个this代表什么?!

If I add a Action Listener then I always use the "this" between the brackets. But what does this "this" stand for ?!

推荐答案

addActionListener方法将当前的类对象作为参数。 这个关键词只是意味着这个对象我现在正在工作。如果您正在使用netbeans,则可以键入this并在其后面加上一段时间来查看this类中定义的所有方法。它应该列出你的类中定义的所有方法,包括任何继承的方法。

The addActionListener method takes the current class object as a parameter. The "this" key word simply means "this object I'm working in right now". If you are using netbeans, you can type "this" and put a period after it to see all the methods defined in "this" class. It should list all the methods that are defined in your class including any inherited methods.

为了完全理解this的含义,你必须先了解它们之间的关系。类和对象。

In order to fully understand what "this" means, you must first understand the relationship between classes and objects.

如果你想了解它,this是对当前对象的引用。

If you want to be technical about it, "this" is a reference to the current object.

这篇关于Java" .addActionListener(this)"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆