简体   繁体   English

NetBeans 平台提要阅读器教程

[英]NetBeans Platform Feed Reader Tutorial

I'm am doing this Netbeans tutorial and i got stuck on this part.( https://platform.netbeans.org/tutorials/nbm-feedreader.html#three )我正在做这个 Netbeans 教程,我被困在这部分。( https://platform.netbeans.org/tutorials/nbm-feedreader.html#three

Here is the code I have for the class implemented:这是我实现的类的代码:

package org.myorg.feedreader;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.windows.TopComponent;

/**
 *
 * @author Kidnapinn
 */
@TopComponent.Description(
        preferredID = "FeedTopComponent",
        persistenceType = TopComponent.PERSISTENCE_ALWAYS)
@TopComponent.Registration(
        mode = "explorer", 
        openAtStartup = true)
@ActionID(
        category = "Window", 
        id = "org.myorg.feedreader.FeedTopComponent")
@ActionReferences({
    @ActionReference(
        path = "Menu/Window", 
        position = 0)
})
@TopComponent.OpenActionRegistration(
        displayName = "#CTL_FeedAction")
@Messages({
    "CTL_FeedTopComponent=Feed Window",
    "HINT_FeedTopComponent=This is a Feed Window"})
private FeedTopComponent() {
    setName(Bundle.CTL_FeedTopComponent());
    setToolTipText(Bundle.HINT_FeedTopComponent());
}
public class FeedTopComponent extends TopComponent {

}

I'm a noob at Java so i don't know what i'm doing wrong.我是 Java 的菜鸟,所以我不知道我做错了什么。 Can you help me?你能帮助我吗?

Add 'NbBundle' to your imports: 将“ NbBundle”添加到您的导入中:

import org.openide.util.NbBundle.*;

This worked for me. 这对我有用。 You might need to add 'Base Utilities API' as a dependency to your FeedReader module. 您可能需要将“基本实用程序API”添加为FeedReader模块的依赖项。 (Project Properties, Libraries, Module Dependencies, Add Dependency;. There is obviously a mistake in the tutorial somewhere as this solution relies on a deprecated import, but it should run now. (项目属性,库,模块依赖关系,添加依赖关系。)由于该解决方案依赖于已弃用的导入,因此本教程中的某个地方显然存在错误,但它应立即运行。

I'm finishing the same tutorial right now, and I can't display it due to error messages.我现在正在完成相同的教程,但由于错误消息,我无法显示它。

Being in learning, I don't know what I missed in the stages.在学习中,我不知道我在各个阶段错过了什么。

The code used is the following:使用的代码如下:

Step 4: Add a constructor to the FeedTopComponent, while again using the @Messages annotation referred to above:第 4 步:将构造函数添加到 FeedTopComponent,同时再次使用上面提到的 @Messages 注释:

@Messages({
    "CTL_FeedTopComponent=Feed Window",
    "HINT_FeedTopComponent=This is a Feed Window"})
private FeedTopComponent() {
    setName(Bundle.CTL_FeedTopComponent());
    setToolTipText(Bundle.HINT_FeedTopComponent());
}

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

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