首页 > 其他 > 详细

e741. 将标签的焦点置于关联的文本框上面

时间:2018-09-06 10:31:29      阅读:105      评论:0      收藏:0      [点我收藏+]

This example associates a label with a text field using setLabelFor(). A mnemonic is set on the label. When the mnemonic keystroke is pressed, the text field will gain the focus.

In the following example, when ALT-L is pressed, the text field gains the focus.

    // Create text field
    JTextField textfield = new JTextField(25);
    
    // Create label and associate with text field
    JLabel label = new JLabel("Text Label");
    label.setDisplayedMnemonic(KeyEvent.VK_L);
    label.setLabelFor(textfield);

 

Related Examples

e741. 将标签的焦点置于关联的文本框上面

原文:https://www.cnblogs.com/borter/p/9596124.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!