简体   繁体   中英

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 )

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. Can you help me?

Add 'NbBundle' to your imports:

import org.openide.util.NbBundle.*;

This worked for me. You might need to add 'Base Utilities API' as a dependency to your FeedReader module. (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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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