码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-09-06 10:50:20      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:pac   moni   elf   new   when   ble   add   text   splay   

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. 将标签的焦点置于关联的文本框上面

标签:pac   moni   elf   new   when   ble   add   text   splay   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!