求教keylistener的问题

Jhomson 2013-09-09 07:26:28
本人菜鸟,在看《java大学简明教程》的教程22时碰到一个很困惑的问题,代码我都贴出来了(原书上的代码,并未修改),就是关于为什么每次按下键盘后,outputJTextArea中的内容就会变化,代码中好像没有有关outputJTextArea更新的语句,求高手指点迷津!!!

outputJTextArea.addKeyListener(

new KeyListener() // anonymous inner class
{
// event handler called when any key is pressed
public void keyPressed( KeyEvent event )
{
outputJTextAreaKeyPressed( event );
}

// event handler called when any key is released
public void keyReleased( KeyEvent event )
{
outputJTextAreaKeyReleased( event );
}

// event handler called when any key is typed
public void keyTyped( KeyEvent event )
{
}

} // end anonymous inner class

); // end call to addKeyListener

outputJTextArea.addFocusListener(

new FocusAdapter() // anonymous inner class
{
// event handler called when outputJTextArea loses focus
public void focusLost( FocusEvent event )
{
outputJTextAreaFocusLost( event );
}

} // end anonymous inner class

); // end call to addFocusListener

...全文
91 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
调皮的芋头 2013-09-09
  • 打赏
  • 举报
回复
看下 outputJTextAreaKeyPressed( event ) 方法的具体实现

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧