Welcome to the user guide for the JOutlookNavBar Swing Component. This guide will help to get you started with this powerful interface navigation component, designed to simulate the navigation bar found in Microsoft's Outlook.
There are 2 ways to create the JOutlookNavBar: either using the default no-arguments constructor, which will give you an empty CategoryModel, or by passing in an already created CategoryModel - this will be covered later.
JOutlookNavBar myOutlookBar = new JOutlookNavBar();
A fully functioning JOutlookNavBar consists of a number of NavBarCategory classes, each containing one or more NavBarItems. Typically you would create the NavBarItems first, then add them to the NavBarCategory, which could then be added to the data model of the JOutlookNavBar.
Constructing a NavBarItem is easy. The constructor takes a single String parameter - this is the text that will be displayed on the Category panel.
Once the item has been created, there a lots of configuration options you can apply. The most common are:
Here is a very simple example:
NavBarItem configItem = new NavBarItem("Configuration");
configItem.setIcon(new ImageIcon(getClass().getResource("/images/configuration.gif")));
configItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
statusBar.setText("Configuration item selected...");
}
});
Each NavBarItem has 3 states - item is selected, item is not selected but the mouse is over it, and item is not selected and the mouse is over it. A state represents the following aspects of the display of an item:
Please check out the JavaDocs for more details on how to set these parameters. A NavBarCategory has default values for each of these three states that will be applied to a NavBarItem when it is added to its category. These will override any states already present in the item, so if you want to set individual state properties for an item, do so AFTER it has been added to its category.
The NavBarCategory class represents two things - a button header and a panel containing the NavBarItems you add to it.
NavBarCategory exampleCategory = new NavBarCategory("Examples");
The constructor takes a single String parameter. This is used as the title displayed on the button header. The font, background and text color can be changed for each header button.
To add an item to a category:
exampleCategory.addItem(configItem);
ActionListeners can be registered against a NavBarCategory. These will be informed every time the header button is clicked on - even if the category is already open. You can use the isOpen() method to determine if a category is open or not.
Each JOutlookNavBar has a data model associated with it. The data model - represented by the CategoryModel class - is responsible for holding all of the categories used by a particular JOutlookNavBar, and also for holding any data model listeners. An event will be fired to these listeners when a category is added or removed from the data model.
A DefaultCategoryModel is created automatically when you use the no-arguments constructor of the JOutlookNavBar. This should be sufficient for most applications, but you can create you own data model by extending the abstract CategoryModel class. Such sub-classes should always fire a CategoryDataEvent when a category is added to or removed from the data model.
To access the model of a JOutlookNavBar:
CategoryModel model = myOutlookBar.getModel();
And to add or remove a category from a model:
model.addCategory(category1); model.removeCategory(category1);
Anti-aliased text draws the various elements of the JOutlookNavBar with smooth edges, vastly improving the look of the component. To enable this feature, use the following code:
JOutlookNavBar myNavBar = new JOutlookNavBar(); myNavBar.setAntiAliased(true);
And to disable the anti-aliasing:
myNavBar.setAntiAliased(false);
There is one additional method to allow you to query the current state of the anti-aliasing:
boolean isAA = myNavBar.isAntiAliased();
Each NavBarCategory you create can be assigned a different background renderer, as provided by the Renderers set of classes also from SyGem Software. For example, to achieve a "Metal-shaded" look, a gradient background renderer could be used:
BackgroundRenderer back = new GradientBackgroundRenderer(new Color(255,255,255),new Color(211,207,196)) NavBarCategory cat1 = new NavBarCategory("Testing"); cat1.setBackgroundRenderer(back);
The animation speed of the NavBarCategorys can be easily adjusted - there are two variables to consider in the animation:
Increasing the number of frames in the animation will make the animation appear smoother, but will take longer. Similarly, increasing the delay will make the animation take longer, but larger delays may look jerky.
// Set the number of animation frames myOutlookBar.setAnimationFrames(10); // And set the animation delay myOutlookBar.setAnimationDelay(100);
The time taken for the animation is equal to the number of frames multiplied by the animation delay - in the example above, 10 frames x 100 milliseconds delay = 1000 milliseconds, or 1 second. This will produce a nice smooth animation.
Like most of the SyGem Swing Components, the JOutlookNavBar has been created as a JavaBean, making it simple to use in conjunction with your favourite Java IDE. All you need to do is import the JOutlookNavBar JAR file into the IDE, and it should become available in the component palette of your choice. Please refer to the instruction manual for your IDE for more details on using and importing JavaBeans.
I hope you enjoy using the JOutlookNavBar - if you need any help using this or any of our components, please email us: joutlooknavbar@sygem.com