Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Set Window Title for a NetBeans MultiViewElement

DZone's Guide to

Set Window Title for a NetBeans MultiViewElement

· Java Zone
Free Resource

The single app analytics solutions to take your web and mobile apps to the next level.  Try today!  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();
        }
    }

 

CA App Experience Analytics, a whole new level of visibility. Learn more. Brought to you in partnership with CA Technologies.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}