简体   繁体   English

如何在 Netbeans 中启用 jLabel 的“生成助记符代码”属性?

[英]How to enable "Generate Mnemonics Code" property of jLabel in Netbeans?

I am using Netbeans IDE, Version 8.1.我正在使用 Netbeans IDE,版本 8.1。 How can we use Generate Mnemonics Code Property of jLabel?我们如何使用jLabel的Generate Mnemonics Code Property? Kindly let me know, how can I use this and where is it useful?请让我知道,我该如何使用它以及它在哪里有用? As shown in the image, I want to edit highlighted property如图所示,我想编辑突出显示的属性

To use this, check the option to enable it and in Text of the Label choose a word to create a Mnemonic and put a & before it it should create it for you.要使用它,请选中启用它的选项,然后在 Label 的文本中选择一个单词来创建助记符,并在它应该为您创建助记符之前放一个 &。

For instance you want to create a Mnemonic to when the user choose Alt+F it should choose the label whit the text "First".例如,您想创建一个助记符,当用户选择 Alt+F 时,它应该选择带有文本“First”的 label。 To do so your text should be "&First".为此,您的文本应为“&First”。

For more information and some rules check the netbeans faq .有关更多信息和一些规则,请查看 netbeans常见问题解答。

Okay, I know this question is old, but I stumbled upon this myself and didn't know how to solve it.好的,我知道这个问题很老,但我自己偶然发现了这个问题,不知道如何解决它。 So here is the answer for the few people that end up searching for the problem online.因此,这是最终在线搜索问题的少数人的答案。 The problem is actually, that the checkbox "Generate Mnemonics Code" is disabled in Netbeans.问题实际上是,在 Netbeans 中禁用了“生成助记符代码”复选框。 This is the case when the package org.openide.awt is not in the classpath of the current project.当 package org.openide.awt不在当前项目的类路径中时就是这种情况。 Just add the following to your pom.xml if you use maven and you can finally use this feature again:如果您使用 maven,只需将以下内容添加到您的pom.xml中,您终于可以再次使用此功能:

<dependency>
    <groupId>org.netbeans.api</groupId>
    <artifactId>org-openide-awt</artifactId>
    <version>RELEASE140</version>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM