java 如何使一個(gè)JPanel始終獲取焦點(diǎn)
3 回答

ABOUTYOU
TA貢獻(xiàn)1812條經(jīng)驗(yàn) 獲得超5個(gè)贊
在鼠標(biāo)事件中,增加下列語(yǔ)句即可:this為JPanel面板:
if (!this.isFocusable())
this.setFocusable(true); //讓面板能夠直接獲取焦點(diǎn),以響應(yīng)鍵盤事件;
if (!this.isFocusOwner())
this.requestFocus();
添加回答
舉報(bào)
0/150
提交
取消