Over a million developers have joined DZone.

Set Window Title for a NetBeans MultiViewElement

· Java Zone

Navigate the Maze of the End-User Experience and pick up this APM Essential guide, brought to you in partnership with CA Technologies

When removing the default source editor for a DataObject, the editor window no longer displays the name of the file you are editing. To solve this, a few changes need to be made to the default editor of your custom file type (implementation of MultiViewElement):

Store the callback:

    private transient MultiViewElementCallback callback;

    @Override
    public void setMultiViewCallback(MultiViewElementCallback callback) {
        this.callback = callback;
    }

Create an update name method:

    public void updateName() {
        if (callback != null) {
            String name = getLookup().lookup(MyDataObject.class).getName();
            TopComponent tc = callback.getTopComponent();
            tc.setHtmlDisplayName(name);
            tc.setDisplayName(name);
            tc.setName(getName());
            tc.setToolTipText(getToolTipText());
        }
    } 

Make sure the name is updated when the component is showing:

    @Override
    public void componentShowing() {
        if (callback != null) {
            updateName();
        }
    }

 

Thrive in the application economy with an APM model that is strategic. Be E.P.I.C. with CA APM.  Brought to you in partnership with CA Technologies.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}