februari 22, 2011

Get the application title inside your platform application

I'm adding some information into the platform applications title bar and I have hard coded the application name title in one of my classes. This works but when the application name changes (for example version/release number) I have to remember to change in two places (my class and in the branding dialog box).

Today I finally did have a look how to get the application title in my code and it was this simple:

NbBundle.getBundle("org.netbeans.core.windows.view.ui.Bundle").getString("CTL_MainWindow_Title");

[source language="java"][/source]

And to set the titlebar of the application:

SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
        WindowManager.getDefault().getMainWindow().setTitle(NbBundle.getBundle("org.netbeans.core.windows.view.ui.Bundle").getString("CTL_MainWindow_Title") + " - " + myOtherInformationIWantInTheTitleBar);
    });