本人菜鸟,在看《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 addFocusListenerjavakeylistenerJTextArea内容更新
{
// 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 addFocusListenerjavakeylistenerJTextArea内容更新
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货