getComponent()与getSource()
Component[] items = 父控件.getComponents(); 获取父控件里的控件,返回Component类的数组。如panel中的许多button
e.getSource() 获取发生Event的对象。
//强制转换为抽象按钮:AbstractButton是JButton、JCheckBox、JRadioButton的父类
//由于不知道谁会被选中,所以使用它们的父类
AbstractButton btn=(AbstractButton)e.getSource();//发生Event的源头
getComponent()与getSource()的更多相关文章
- JAVA-getComponent()与getSource()
两个方法都是获取发生事件的事件源对象,区别也许是返回的类型不同,如果是getSource()需要强制类型转换为Component 对象:而getComponent()无需转换: API的说明如下: 类 ...
- GetComponent
GetComponent 的几种写法: 1.AutoRotation cmp1=(AutoRotation) GetComponent(typeof(AutoRotation)); 2.AutoRot ...
- react按需加载(getComponent优美写法),并指定输出模块名称解决缓存(getComponent与chunkFilename)
react配合webpack进行按需加载的方法很简单,Route的component改为getComponent,组件用require.ensure的方式获取,并在webpack中配置chunkFil ...
- 关于Unity 获得和使用GetComponent<MeshFilter>().mesh时的心得
原文地址:http://blog.sina.com.cn/s/blog_7d9405e50100s061.html 今天在使用Unity3D的时候遇到了一个问题:_tesGameObject是在Pro ...
- transform.rotation和GetComponent<Rigidbody>().MoveRotation
同时在UPDATE和FIXED UPDATE中调整 旋转 并未出现闪,而是一直以UPDATE中的为准,可认为MoveRotation调用后在UPDATE中生效 using System.Collect ...
- unity, GetComponent<MeshRenderer>().sharedMaterial 与 GetComponent<MeshRenderer>().material
我多个物体用的是同一个material,当我用gameObject.GetComponent<MeshRenderer>().sharedMaterial.SetColor("_ ...
- unity, GetComponent<Renderer>().bounds.size vs GetComponent<MeshFilter>().sharedMesh.bounds.size
GetComponent<MeshFilter>().sharedMesh.bounds.size获得的是未经缩放的大小. GetComponent<Renderer>().b ...
- MMT事务处理来源类型-INV_OBJECT_GENEALOGY.GETSOURCE
INV_OBJECT_GENEALOGY.GETSOURCE (MTL_MATERIAL_TRANSACTIONS.ORGANIZATION_ID, ...
- 使用TryGetComponent取代GetComponent以避免Editor中的内存分配
作为Unity开发人员,可能或多或少都会遇到过一个常见的Unity的GC分配问题——在Editor中使用GetComponent方法来获取一个不存在的Component时会分配额外的内存.就像下图 需 ...
随机推荐
- B. Divisor Subtraction
链接 [http://codeforces.com/contest/1076/problem/B] 题意 给你一个小于1e10的n,进行下面的运算,n==0 结束,否则n-最小质因子,问你进行多少步 ...
- C. Sequence Transformation
链接 [http://codeforces.com/contest/1059/problem/C] 题意 给你一个n,有个序列有n个元素分别时1 ~ n,每次去掉一个元素输出剩下元素的GCD,使得最后 ...
- 第三个Sprint冲刺第七天(燃尽图)
- 携程Apollo配置中心架构深度剖析
转自:http://www.uml.org.cn/wfw/201808153.asp 一.介绍 Apollo(阿波罗)[参考附录]是携程框架部研发并开源的一款生产级的配置中心产品,它能够集中管理应用在 ...
- node多文件处理方法
let events = require('events'); let fs = require('fs'); // 将readfile封装成一个方法 多文件处理 function fnreadFi ...
- 软件工程_9th weeks
PSP DATE START_TIME END_TIME EVENT TYPE TIME 4.30-5.3 5:30 4:00 旅游 娱乐 72h 5.3 14:00 17:0 ...
- mysql问题处理积累
1.mysql errors:message from server: "Host 'xxx' is blocked because of many connection errors; u ...
- python之tkinter使用-复选框操作
# tkinter复选框操作 import tkinter as tk root = tk.Tk() root.title('问卷调查') root.geometry('220x80') # 设置窗口 ...
- linux-shell系列7-ssh密匙生成分发
sshpass 该软件就是为ssh提供密码使用的yum install sshpass -y 批量分发脚本内容 #!/bin/bash. /etc/rc.d/init.d/functions # ...
- mvc Filters 过滤器
项目需要控制controller和action的访问权限. 看了下资料,发觉还是很方便的. 首先在mvc项目下创建一个文件夹 Filters, 然后在Filters中创建一个类.代码如下 namesp ...