DevFaqMainTitle

(Difference between revisions)
 
(9 intermediate revisions not shown)
Line 3: Line 3:
For production deployment, it could be required to only show the branding name.
For production deployment, it could be required to only show the branding name.
-
There are two possible steps to achieve it:
+
There are several possible steps to achieve it:
-
== 1º.- '''Remove the build number'''. ==
+
== Remove the build number ==
-
Open this file:  
+
The title of your application is located in a resource bundle:
-
...\branding\modules\org-netbeans-core-windows.jar\org\netbeans\core\windows\view\ui\Bundle.properties
+
<pre>...\branding\modules\org-netbeans-core-windows.jar\org\netbeans\core\windows\view\ui\Bundle.properties</pre>
-
in your project, and remove existing {0} tokens
+
As of NetBeans 6.9, it is possible to use the [[NewAndNoteWorthy#Branding_Editor | Branding Editor]] to edit this resource.
-
:'''CTL_MainWindow_Title=AppBrandingName {0}'''
+
To remove the version number prior to 6.9, manually edit the file and remove existing {0} tokens:
 +
:'''CTL_MainWindow_Title=AppBrandingName {0}'''
:'''CTL_MainWindow_Title_No_Project=AppBrandingName {0}'''
:'''CTL_MainWindow_Title_No_Project=AppBrandingName {0}'''
Line 21: Line 22:
:'''CTL_MainWindow_Title=AppBrandingName'''
:'''CTL_MainWindow_Title=AppBrandingName'''
-
 
:'''CTL_MainWindow_Title_No_Project=AppBrandingName'''
:'''CTL_MainWindow_Title_No_Project=AppBrandingName'''
Build number will not show in the application main title.
Build number will not show in the application main title.
 +
== Change main title at runtime ==
 +
 +
Inside the ModuleInstaller class for the GUI module:
 +
 +
@Override
 +
public void restored() {
 +
  // some other code may go here...
 +
    WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
 +
      @Override
 +
      public void run() {
 +
      JFrame mainFrame = (JFrame) WindowManager.getDefault().getMainWindow();
 +
      mainFrame.setTitle("Modified main title");
 +
      });
 +
    }
 +
  // some other code may go here...
 +
}
 +
 +
 +
A word of caution related to porting existing Swing applications to NetBeans Platform.
 +
 +
'''This will not work!'''
 +
 +
@Override
 +
public void restored() {
 +
  // some other code may go here...
 +
    SwingUtilities.invokeLater(new Runnable(){
 +
      @Override
 +
      public void run() {
 +
      JFrame mainFrame = (JFrame) WindowManager.getDefault().getMainWindow();
 +
      mainFrame.setTitle("Modified main title");
 +
      });
 +
    }
 +
  // some other code may go here...
 +
}
 +
 +
Although it will not show any errors, '''the main title will not be set!''' in this case.
 +
 +
== Other Options ==
-
== '''2º.- Change main title at runtime.''' ==
+
See also:
 +
* [http://blogs.kiyut.com/tonny/2007/08/06/netbeans-platform-branding-and-version-info/ Branding version numbers using Ant]
 +
* [[DevFaqVersionNumber]]

Current revision as of 15:56, 18 November 2010

By default, the main title shows the branding name plus the build number.

For production deployment, it could be required to only show the branding name.

There are several possible steps to achieve it:

Remove the build number

The title of your application is located in a resource bundle:

...\branding\modules\org-netbeans-core-windows.jar\org\netbeans\core\windows\view\ui\Bundle.properties

As of NetBeans 6.9, it is possible to use the Branding Editor to edit this resource.

To remove the version number prior to 6.9, manually edit the file and remove existing {0} tokens:

CTL_MainWindow_Title=AppBrandingName {0}
CTL_MainWindow_Title_No_Project=AppBrandingName {0}

so it will be as:

CTL_MainWindow_Title=AppBrandingName
CTL_MainWindow_Title_No_Project=AppBrandingName

Build number will not show in the application main title.

Change main title at runtime

Inside the ModuleInstaller class for the GUI module:

@Override
public void restored() {
  // some other code may go here...
   WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
     @Override
     public void run() {
      JFrame mainFrame = (JFrame) WindowManager.getDefault().getMainWindow();
      mainFrame.setTitle("Modified main title");
     });
   }
  // some other code may go here...
}


A word of caution related to porting existing Swing applications to NetBeans Platform.

This will not work!

@Override
public void restored() {
  // some other code may go here...
   SwingUtilities.invokeLater(new Runnable(){
     @Override
     public void run() {
      JFrame mainFrame = (JFrame) WindowManager.getDefault().getMainWindow();
      mainFrame.setTitle("Modified main title");
     });
   }
  // some other code may go here...
}

Although it will not show any errors, the main title will not be set! in this case.

Other Options

See also:

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo