在此组件构造函数之外为某些swing组件添加KeyListener对象时,KeyAdapter不起作用

| 当我尝试为该组件构造函数之外的某些摆动组件添加KeyListener对象时,KeyListener之后没有回答,为什么?例如:
    public class ActionViewer extends SimpleViewer
                              implements ActionListener

    {
        public ActionViewer(Dimension __wndSize, String pgnPath, 
                            PerspectiveProjection __persp)
        {
            super(__wndSize, pgnPath, __persp);

            ...
            cMng=null;
            ...
        }
        ///
        public void setCamera(double xMin, double xMax,
                              double yMin, double yMax,
                              double zMin, double zMax)
        {
            if(!isCameraInit())
            {
                if(cMng==null)
                    cMng=new CameraControl();
                this.addKeyListener((KeyListener)cMng);
                fCamInit=true;
            }
            setCameraBounds(xMin, xMax, yMin, yMax, zMin, zMax);
        }
    ...
}
当我在main中调用setCamera时,没有任何反应。
...
ActionViewer scene = new ActionViewer(wndSize, pgnPath, persp);
scene.setCamera(xMin, xMax, yMin, yMax, zMin, zMax);
...
    
已邀请:
        我认为初始化存在一些问题,您能否仅通过
try{}catch
所有方法
setCamera
检查init侦听器的位置并打印所有问题,它应该可以帮助您找到问题。     

要回复问题请先登录注册