Article View: borland.public.jbuilder.java.language
Article #18291Q: catching KeyEvents in JTextField ?
From: yzhou
Date: Thu, 16 Jul 1998 00:00
Date: Thu, 16 Jul 1998 00:00
78 lines
2593 bytes
2593 bytes
Hi,
I am having problem in catching Keyboard Events in a
simple Swing JTextField. It works on IE and Windows.
On some Unix platforms, the JTextField does not accept
keyborad typing at all. On Netscape (Windows), if I
minimize the browser and restore it, the JTextField does
not accept keyboard typing. My browsers are the latest
ones with JDK1.1 support.
Anybody could give some hints ?
Thanks in advance.
Yan Zhou
yzhou@mtu.edu
The program is enclosed.
There is a JTextField placed in a BevelPanel.
The JTextField just does not accept keyboard events
under some Unix platforms (e.g. Solaris 2.5, Linux)
package DaJText;
import java.awt.*;
import java.awt.event.*;
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
import com.sun.java.swing.*;
public class Applet1 extends JApplet {
boolean isStandalone = false;
BevelPanel bevelPanel1 = new BevelPanel();
JTextField jTextField1 = new JTextField();
BorderLayout borderLayout1 = new BorderLayout();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public Applet1() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jTextField1.requestFocus(); // somebody suggests this
jTextField1.setText("");
this.getContentPane().setLayout(borderLayout1);
this.getContentPane().add(bevelPanel1, BorderLayout.CENTER);
bevelPanel1.add(jTextField1, new XYConstraints(135, 115, 109, 25));
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
}
Technical Details
Message-ID:
<35AE2E58.5E800DD5@mtu.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5619,87ae21a493242e27,start X-Google-Attributes: gidf5619,public X-Google-Thread: f74b3,87ae21a493242e27,start X-Google-Attributes: gidf74b3,public From: yzhou <yzhou@mtu.edu> Subject: Q: catching KeyEvents in JTextField ? Date: 1998/07/16 Message-ID: <35AE2E58.5E800DD5@mtu.edu> X-Deja-AN: 372068180 Content-Transfer-Encoding: 7bit Organization: Michigan Tech Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language,borland.public.jbuilder.jbcl