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

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

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();
        }
    }

 

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

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 }}