遊客:  註冊 | 登錄 | 幫助





標題: [求助] Pressing Tab key in IE with latest JRE version
  stanfish     Rank: 2Rank: 2
藍之初
性別 保密
UID 11127

精華 0
帖子 9
積分 100   詳情

閱讀權限 30
註冊 2006-9-4
來自
狀態 離線

 
 
 
 
發表於 2006-10-26 04:16 PM  資料  個人空間  短訊  加為好友 
Pressing Tab key in IE with latest JRE version

Hi,



I have question about typing "TAB" key in Java Applet in internet explorer with JRE 1.05_08 or above.
When I type any key other than "TAB", the function, processEvent, will be called 3 times to process keyPressed, keyTyped and keyReleased.  However, when I type "TAB" key, processEvent is only called once to process keyTyped and the focus goes outside the applet.

Is there any way that the focus won't get lost when typing the "TAB" key?

Note that this problem only happens in IE browser with JRE 1.05_08 or above.  It works well in Firefox and netscape with any JRE version and works well in IE with JRE 1.05_06 and below.


The following is my code:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class KeyEventDemo extends Applet implements KeyListener, FocusListener {
        public KeyEventDemo() {
                super();
                addKeyListener(this);
                addFocusListener(this);
        }
        public void keyTyped(KeyEvent e) {
                System.out.println("KEY TYPED: e="+e);
        }
        public void keyPressed(KeyEvent e) {
                System.out.println("KEY PRESSED: e="+e);
        }
        public void keyReleased(KeyEvent e) {
                System.out.println("KEY RELEASED: e="+e);
        }
        public boolean keyDown(Event e, int key) {
                System.out.println("keyDown: e="+e);
                return false;
        }
        public boolean keyUp(Event e, int key) {
                System.out.println("keyUp: e="+e);
                return false;
        }
        public void processEvent(AWTEvent e) {
                System.out.println("processEvent : e="+e);
        }
        public void focusGained(FocusEvent e){System.out.println("FocusGained");}
        public void focusLost(FocusEvent e){System.out.println("FocusLost");}
        public void paint ( Graphics g ){
                this.setBackground ( Color.blue );
        }
        public boolean isFocusTraversable() {
                return true;
        }
        public boolean getFocusTraversalKeysEnabled() {
                return false;
        }
}


Thanks very much!

頂部

快速美言
           


當前時區 GMT+8, 現在時間是 2024-5-6 11:29 AM

    Powered by Discuz!  © 2001-2007 Comsenz Inc.   
Processed in 0.008001 second(s), 7 queries

清除 Cookies - 聯繫我們 - LIPS Corner 新天藍 - Archiver