当前位置: 技术问答>java相关
100分请教!!!如何在APPLET的文本框中加光标
来源: 互联网 发布时间:2015-07-27
本文导语: 我是这样写的 public MyApplet extends Applet { public void init() { ..... Panel p = new Panel(); TextField t = new TextField(); t.RequestFocus(); p.add(t); } } 请问,如何在APPLET一运行时,就...
我是这样写的
public MyApplet extends Applet
{
public void init()
{
.....
Panel p = new Panel();
TextField t = new TextField();
t.RequestFocus();
p.add(t);
}
}
请问,如何在APPLET一运行时,就让APPLET的这个文本框中自动有一个光标在,用户可以直接输入字符,而不用在文本框中用鼠标点一下,才可以输入。我加的t.RequestFocus();好象根本不起作用????
谢谢!!!
public MyApplet extends Applet
{
public void init()
{
.....
Panel p = new Panel();
TextField t = new TextField();
t.RequestFocus();
p.add(t);
}
}
请问,如何在APPLET一运行时,就让APPLET的这个文本框中自动有一个光标在,用户可以直接输入字符,而不用在文本框中用鼠标点一下,才可以输入。我加的t.RequestFocus();好象根本不起作用????
谢谢!!!
|
Developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event. If this request is denied because this Component's top-level Window cannot become the focused Window, the request will be remembered and will be granted when the Window is later focused by the user.
(载自jdk api)
就是说你必须保证你的applet是一个有焦点的窗口!
try applet.requestFocus();
(载自jdk api)
就是说你必须保证你的applet是一个有焦点的窗口!
try applet.requestFocus();