今天在 BOS开发中,,给单据叙事簿上(hangshi的配餐单)的条件文本框增加回车自动刷新的事件,发现如下监听器都不起作用:
kDTextField1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent arg0) {System.out.println("回车了!");}});//按理说ActionListener就是回车事件,不知道为什么不起作用,是不是单据超类把回车事件给截获了?kDTextField1.addKeyListener(new KeyListener(){public void keyPressed(KeyEvent arg0) {if(arg0.getKeyCode() == 13){System.out.println("enter key!");}};public void keyReleased(KeyEvent arg0) {// TODO 自动生成方法存根System.out.println("enter key!");}public void keyTyped(KeyEvent arg0) {// TODO 自动生成方法存根System.out.println("enter key!");}});
最后只有用下面的焦点监听器来实现,正好是失去焦点和回车都可以:kDTextField1.addFocusListener(new FocusListener(){public void focusLost(FocusEvent arg0) {try{ txtAccount_Changed();}catch(Exception e){ handUIException(e);}};public void focusGained(FocusEvent arg0) {// TODO 自动生成方法存根}});
找回自我,歇够了,再飞回来,继续面对自己的人生。