Posts Tagged ‘StatusBar’

Recipe 2: Status Bar

February 12, 2011 Leave a comment

How do I create a status bar in Netbeans RCP?


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 {
   public Component getStatsLineElement() {
     return aComponent; // e.g. a JLabel, a JPanel etc.