Q:

leaking this constructor java with netbeans

I'm using customButtons as a container for a load of JButtons. I acquire the buttons via name (but via a configuration file):
getComponent("btn1"); 

I've done it this way to have a pretty list of buttons, a simple overview of functions, and a reference to the correct panel "jpt" to have all of the help the compiler gives me.
The order, number and selection of buttons also need to be configurable by non programmers  - and i've found a list of button variable names to work well).
The problem is: Netbeans 7.4 gives me the warning "Leaking this in constructor" (line 9), which is true, because i do. Is there a more correct way to achieve the same result ?
public class CustomButtons extends javax.swing.JPanel {

    CustomJPanel jpt;
    HashMap<String, Component> components;

    public CustomButtons (CustomJPanel jpt) {
    this.jpt = jpt;
    initComponents();
    components = getAllComponentsInContainer(this);
}

public Component getComponent(String name) {
    return components.get(name);
}

private HashMap<String, Component> getAllComponentsInContainer(Container root) {
    HashMap<String, Component> comps = new HashMap<>();
    for (Component c : root.getComponents()) {
        comps.put(c.getName(), c);
        if (c instanceof Container) {
            comps.putAll(getAllComponentsInContainer((Container) c));
        }
    }

    return comps;
}

A:

Provided that getComponents() is guaranteed to be initialised by the time you call getAllComponentsInContainer(this), you may not be too concerned about the warning - it is mainly there to warn you about the possibility of your instance not being completely initialised yet.
If you want to avoid the warning, you could change the getAllComponentsInContainer to just accept the result of getComponents() instead:
components = getAllComponents(getComponents());
...
private HashMap<String, Component> getAllComponents(Component[] containerComponents) {
    HashMap<String, Component> comps = new HashMap<>();
    for (Component c : containerComponents) {
        comps.put(c.getName(), c);
        if (c instanceof Container) {
            comps.putAll(getAllComponents((Container) c).getComponents());
        }
    }

    return comps;
}

Alternatively you could, for example, add an initialise method to your class that needs to be called after the constructor is finished (but this means you risk forgetting to call it somewhere):
public void initialise() {
    components = getAllComponents(getComponents());
}

