textField

A TextField object is a text component that allows for the editing of a single line of text.
For example, the following image depicts a frame with four text fields of varying widths. Two of these text fields display the predefined text “Hello”.
文本框对象是一个文本组件,允许编辑一行文本。
例如,下面的图片描绘的是一个框架,四个不同宽度的文本字段。
两个文本字段显示预定义的文本“Hello”。
这里写图片描述
Here is the code that produces these four text fields:


TextField tf1, tf2, tf3, tf4;
// a blank text field
tf1 = new TextField();
// blank field of 20 columns
tf2 = new TextField(“”, 20);
// predefined text displayed
tf3 = new TextField(“Hello!”);
// predefined text in 30 columns
tf4 = new TextField(“Hello”, 30);
Every time the user types a key in the text field, one or more key events are sent to the text field. A KeyEvent may be one of three types: keyPressed, keyReleased, or keyTyped. The properties of a key event indicate which of these types it is, as well as additional information about the event, such as what modifiers are applied to the key event and the time at which the event occurred.
每次用户输入文本中的一个关键领域,关键事件被发送到一个或多个文本字段。可以三种类型之一:KeyEvent keyPressed,keyReleased或keyTyped。关键事件的性质表明哪一个类型,以及关于事件的附加信息,如修饰符应用于关键事件和事件发生的时间。
The key event is passed to every KeyListener or KeyAdapter object which registered to receive such events using the component’s addKeyListener method. (KeyAdapter objects implement the KeyListener interface.)
关键事件传递给每一个KeyListener或KeyAdapter对象注册使用组件的addKeyListener方法接收这样的事件。(KeyAdapter对象实现KeyListener接口)。

It is also possible to fire an ActionEvent. If action events are enabled for the text field, they may be fired by pressing the Return key.
也可以激发ActionEvent。如果行动事件启用文本字段,它们可能被按下回车键。
The TextField class’s processEvent method examines the action event and passes it along to processActionEvent. The latter method redirects the event to any ActionListener objects that have registered to receive action events generated by this text field.
文本框类的processEvent方法考察了操作事件并将它传递到processActionEvent。后一种方法将事件重定向到任何ActionListener对象注册接收操作事件生成的文本字段。
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值