
java 如何使一个JPanel始终获取焦点
展开全部
在鼠标事件中,增加下列语句即可:this为JPanel面板:
if (!this.isFocusable())
this.setFocusable(true); //让面板能够直接获取焦点,以响应键盘事件;
if (!this.isFocusOwner())
this.requestFocus();
if (!this.isFocusable())
this.setFocusable(true); //让面板能够直接获取焦点,以响应键盘事件;
if (!this.isFocusOwner())
this.requestFocus();
2013-07-10
展开全部
JPanel里面的元件,还差不多。 那就在失去焦点的时候,不让失去
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询