Archive

Archive for February, 2011

Recipe 3: ToolBar

February 12, 2011 Leave a comment

Problem:
How do I display a toolbar in Netbeans RCP?

Solution:
To display a ToolBar in Netbeans RCP, a class must implement the Presenter.Toolbar interface:

package my.package.toolbar;
public class AToolBar implements Presenter.Toolbar {
   @Override
   public Component getToolbarPresenter() {
       return aComponent;            // e.g. a JLabel, a JPanel etc.
   }
}
However, this is not enough. You need to edit layer.xml too like so:
<filesystem>
 <folder name="Actions">
  <folder name="View">
   <file name="my-package-toolbar-AToolBar.instance">
     <attr name="delegate" newvalue="my.package.toolbar.AToolBar"/>
     <!--attr name="displayName" bundlevalue="my.package.toolbar.Bundle#CTL_AToolBar"/-->
     <attr name="noIconInMenu" boolvalue="true"/>
   </file>
  </folder>
 </folder>
<folder name="Toolbars">
 <folder name="MyToolBar">
  <file name="my-package-toolbar-AToolBar.shadow">
    <attr name="originalFile" stringvalue="Actions/View/my-package-toolbar-AToolBar.instance"/>
    <attr name="position" intvalue="10"/>
   </file>
  </folder>
 </folder>
</filesystem>

You need to add your toolbar under <Toolbars> folder. Then you can declare the actual path to the class using <originalFile> attribute.

Categories: Toolbar

Recipe 2: Status Bar

February 12, 2011 Leave a comment

Problem:
How do I create a status bar in Netbeans RCP?

Solution:

If you need only to display text in the status bar, then you can easily do that by issuing the command: StatusDisplayer.getDefault().setStatusText(“Status message”).
More complex components are handled by the Netbeans RCP API as implementations of the service StatusLineElementProvider. It allows flexible loose coupled management of the swing components that are displayed in the status bar. The developer needs only to provide an implementation of the StatusLineElementProvider interface and implement its single method getStatusLineElement(). For Netbeans to be able to find it, you need to add the implementation to the default lookup (see Recipe 1), by annotating it with @ServiceProvider as shown in the code below. The most left status bar has position = 1, the next one to the right position = 2 etc.

@ServiceProvider(service = StatusLineElementProvider.class, position=1)
public class AStatusBar implements StatusLineElementProvider {
   @Override
   public Component getStatsLineElement() {
     return aComponent; // e.g. a JLabel, a JPanel etc.
   }
}

Books on Netbeans RCP

February 12, 2011 Leave a comment

A number of books, not many, have been written for the Netbeans Rich Client Platform:

  • Anderson G., Anderson P. (2014), JavaFX Rich Client Programming on the Netbeans Platform, Addison-Wesley.
  • Bock H. (2012), The Definite Guide to NetBeans Platform 7, Apress.
  • Bourdeau T., Tulach J., Wielenga G. (2007), Rich Client Programming, Plugging into the NetBeans Platform, Prentice Hall.
  • Myatt A. (2008), Pro NetBeans IDE 6 Rich Client Platform Edition, Apress.
  • Petri J. (2009), NetBeans Platform 6.9 Developer’s Guide, Packt Publishing.
  • Toulach J. (2008), Practical API Design Confessions of a Java Framework Architect, Apress.
  • Wexbridge J., Nyland W. (2014), NetBeans Platform for Beginners, Leanpub.
Categories: Books