Home > StatusBar > Recipe 2: Status Bar

Recipe 2: Status Bar

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.
   }
}
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: