Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6738135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:19:52+00:00 2026-05-26T11:19:52+00:00

I’m having problems with the NetBeans Nodes API. I have this line of code:

  • 0

I’m having problems with the NetBeans Nodes API.

I have this line of code:

Node n = (new MyNode(X)).getChildren().getNodeAt(Y);

The call to new MyNode(X) with the same X always initializes a MyNode the same way, independent of the context.

When I place it by itself (say, in an menu action), it successfully gets the Yth child, but if I put it in an event where other Node/Children stuff happens, it returns null.

MyNode’s Children implementation is a trivial subclass of Children.Keys, which is approximately:

// Node
import org.openide.nodes.AbstractNode;

class MyNode extends AbstractNode {

    MyNode(MyKey key) {
        super(new MyNodeChildren(key));
    } 
}


// Children 
import java.util.Collections;
import org.openide.nodes.Children;
import org.openide.nodes.Node;

public class MyNodeChildren extends Children.Keys<MyKey> {
    MyKey parentKey;

    MyNodeChildren(MyKey parentKey) {
        super(true); // use lazy behavior
        this.parentKey = parentKey;
    }

    @Override
    protected Node[] createNodes(MyKey key) {
        return new Node[] {new MyNode(key)};
    }

    @Override
    protected void addNotify() {
        setKeys(this.parentKey.getChildrenKeys());
    }

    @Override
    protected void removeNotify() {
        setKeys(Collections.EMPTY_SET);
    }
}

// MyKey is trivial.

I assume this has something to do with the lazy behavior of Children.Keys. I have the sources for the API, and I’ve tried stepping through it, but they’re so confusing that I haven’t figured anything out yet.

NetBeans IDE 7.0.1 (Build 201107282000) with up-to-date plugins.

Edit: More details

The line with the weird behavior is inside a handler for an ExplorerManager selected-nodes property change. The weird thing is that it still doesn’t work when the MyNode instance isn’t in the heirarchy that the ExplorerManager is using (it’s not even the same class as the nodes in the ExplorerManager), and isn’t being used for anything else.

Accessing the nodes instead of the underlying model is actually necessary for my use case (I need to do stuff with the PropertySets), the MyNode example is just a simpler case that still has the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:19:53+00:00Added an answer on May 26, 2026 at 11:19 am

    Timon Veenstra on the NetBeans Platform Developers mailing list solved this for me.

    Actions on the explorerManager are guarded to ensure consistency. A
    node selection listener on an explorer manager for example cannot
    manipulate the same explorer manager while handling the selection
    changed event because that would require a read to write upgrade. The
    change will be vetoed and die a silent death.

    Are you adding the MyNode root node to the explorer manager on
    initialization, or somewhere else in a listener?

    My problem line is in an ExplorerManager selection change listener. I guess the Children.MUTEX lock is getting set by ExplorerManager and preventing the Children.Keys instance from populating its Nodes…?

    Anyways, I moved my Node access into a EventQueue.invokeLater(…), so it executes after the selection changed event finishes, and that fixed it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.