📄 controlcollection.java
字号:
package net.sf.fmj.utility;import java.util.Vector;import javax.media.Control;/** * Maintains a list of Control objects. The Controls may be retrieved by classname or interface name. * * @author Warren Bloomer * */public class ControlCollection { private static final Control[] CONTROL_SPEC = new Control[]{}; private Vector controls = new Vector(); /** * Add a Control to the list. * * @param control */ public void addControl(Control control) { synchronized (controls) { controls.add(control); } } /** * Remove a Control from the list. * * @param control */ public void removeControl(Control control) { synchronized (controls) { controls.remove(control); } } /** * Retrieve an array of Controls that control the object. If no controls are supported, * a zero length array is returned. * * @return the array of object controls */ public Control[] getControls() { synchronized (controls) { return (Control[]) controls.toArray(CONTROL_SPEC); } } /** * Retrieve the first Control that implements the given Class or Interface. The * full class name must be used. If the control is not supported then null is returned. * * @return the object that implements the control, or null. */ public Control getControl(String controlType) { try { Class cls = Class.forName(controlType); synchronized (controls) { Control cs[] = getControls(); for (int i = 0; i < cs.length; i++) { if (cls.isInstance(cs[i])) { return cs[i]; } } } return null; } catch (Exception e) { // no such controlType or such control return null; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -