com.sygem.swing.joutlooknavbar
Class NavBarCategory

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycom.sygem.swing.joutlooknavbar.NavBarCategory
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class NavBarCategory
extends javax.swing.JComponent

This class represents a single category, containing one or more items.

Within each category, you can customize the rendering of the background, the font used by the header, and the foreground and background colours as well.

ActionListeners can be registered against the header button - use these to be informed of when a category is selected. NOTE: events will be generated every time the header is clicked on, even if the category is already open. To determine if a category is open, use the isOpen() method.

If the size of the items in the category is larger than the space available, a scroll-bar will be displayed to let users get at all items.

Title: JOutlookNavBar
Description: A Swing component simulating Outlook's Nav Bar
Copyright: Copyright (c) 2004
Company: SyGem Software

Version:
1.2c
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
NavBarCategory(java.lang.String title)
          Standard constructor - The title string will be displayed on the header button.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Registers an ActionListener against the category.
 void addItem(NavBarItem item)
          Adds a NavBarItem to this category.
 BackgroundRenderer getBackgroundRenderer()
          Returns the renderer currently being used for this category.
 NavBarItem getItem(java.lang.String itemText)
          Retrieves a NavBarItem from the category, based on its Text value.
 State getItemSelectedState()
          Returns the State representing the default values an item will inherit when selected.
 State getMouseNotOverState()
          Returns the State representing the default values an item will inherit when the mouse is not over the item, and it is not selected.
 State getMouseOverState()
          Returns the State representing the default values an item will inherit when the mouse is over the item, and it is not selected.
 NavBarItem getSelectedItem()
          Returns the currently selected NavBarItem from this NavBarCategory.
 boolean isOpen()
          Returns true if this category is currently open.
 void openCategory(boolean generateEvent)
          Allows you to programmatically open a NavBarCategory.
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes an ActionListener from this category.
 boolean removeItem(NavBarItem item)
          Removes an item from this category
 void selectNavBarItem(NavBarItem item, boolean generateEvent)
          Allows you to programmatically select a NavBarItem.
 void setBackgroundColor(java.awt.Color c)
          Sets the background color of the category header button.
 void setBackgroundRenderer(BackgroundRenderer backgroundRenderer)
          Registers a new background renderer for this category.
 void setFont(java.awt.Font font)
          Sets the font used on the category header button.
 void setHorizontalAlignment(int alignment)
          Sets the default horizontal text alignment for each of the three states.
 void setHorizontalTextPosition(int textPosition)
          Sets the default horizontal text position for each of the three states.
 void setInsets(java.awt.Insets insets)
          Sets a boundary around each item.
 void setItemColors(java.awt.Color c)
          Sets the default colors for each of the three states.
 void setItemFonts(java.awt.Font font)
          Sets the default font for each of the three states.
 void setItemSelectedState(State s)
          Sets the default set of attributes an item will be given when the item is selected.
 void setMouseNotOverState(State s)
          Sets the default set of attributes an item will be given when the mouse is not over it, and it is not selected.
 void setMouseOverState(State s)
          Sets the default set of attributes an item will be given when the mouse is moved over it, and it is not selected.
 void setTextColor(java.awt.Color c)
          Sets the foreground (text) color of the category header button.
 void setVerticalAlignment(int alignment)
          Sets the default vertical text alignment for each of the three states.
 void setVerticalTextPosition(int textPosition)
          Sets the default vertical text position for each of the three states.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NavBarCategory

public NavBarCategory(java.lang.String title)
Standard constructor - The title string will be displayed on the header button.

Parameters:
title - The title of this Category
Method Detail

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)

Registers an ActionListener against the category.

ActionEvents are generated whenever the category header is clicked on - even if the category is currently on show.

The getSource() method of the ActionEvent will return the NavBarCategory.

Parameters:
listener - The ActionListener to add

addItem

public void addItem(NavBarItem item)
Adds a NavBarItem to this category.

Parameters:
item - The NavBarItem to add

getBackgroundRenderer

public BackgroundRenderer getBackgroundRenderer()
Returns the renderer currently being used for this category. If no renderer has been assigned, this method will return null.

Returns:
The current BackgroundRenderer

getItem

public NavBarItem getItem(java.lang.String itemText)
Retrieves a NavBarItem from the category, based on its Text value.

Parameters:
itemText - The Text of the item to be retrieved
Returns:
The NavBarItem, or null if no match was found

getItemSelectedState

public State getItemSelectedState()
Returns the State representing the default values an item will inherit when selected.

Returns:
The item-selected State
See Also:
State

getMouseNotOverState

public State getMouseNotOverState()
Returns the State representing the default values an item will inherit when the mouse is not over the item, and it is not selected.

Returns:
The mouse-not-over State
See Also:
State

getMouseOverState

public State getMouseOverState()
Returns the State representing the default values an item will inherit when the mouse is over the item, and it is not selected.

Returns:
The mouse-over State
See Also:
State

getSelectedItem

public NavBarItem getSelectedItem()
Returns the currently selected NavBarItem from this NavBarCategory. If no items are selected, this method will return null.

Returns:
The selected NavBarItem, or null

isOpen

public boolean isOpen()
Returns true if this category is currently open.

Returns:
True if this category is currently open

openCategory

public void openCategory(boolean generateEvent)
Allows you to programmatically open a NavBarCategory. If the category is already open, no action is performed. You may also specify whether or not any ActionListeners associated with the NavBarCategory receive events when the category is opened.
NOTE: The NavBarCategory must have been added to a JOutlookNavBar for this method to have any effect.

Parameters:
generateEvent - A value of TRUE will cause events to be generated

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes an ActionListener from this category.

Parameters:
listener - The ActionListener to remove

removeItem

public boolean removeItem(NavBarItem item)
Removes an item from this category

Parameters:
item - The NavBarItem to remove
Returns:
True if the item was successfully removed

selectNavBarItem

public void selectNavBarItem(NavBarItem item,
                             boolean generateEvent)
Allows you to programmatically select a NavBarItem. The NavBarCategory must have been added to the JOutlookNavBar for this method to have any effect. Also, no effect will be seen immediately if the NavBarCategory is not currently visible.

Parameters:
item - The NavBarItem to be selected.
generateEvent - Set this to TRUE if you want the NavBarItem's ActionListeners to be informed of the selection

setBackgroundColor

public void setBackgroundColor(java.awt.Color c)
Sets the background color of the category header button.

Parameters:
c - The background color of the header button

setBackgroundRenderer

public void setBackgroundRenderer(BackgroundRenderer backgroundRenderer)
Registers a new background renderer for this category.

Parameters:
backgroundRenderer - The BackgroundRenderer to use as the renderer for this category.

setFont

public void setFont(java.awt.Font font)
Sets the font used on the category header button.

Parameters:
font - The Font that will be used on the header button

setHorizontalAlignment

public void setHorizontalAlignment(int alignment)

Sets the default horizontal text alignment for each of the three states.

NOTE: These changes will override changes made to the states of any item before they are added to a category.

Parameters:
alignment - One of the following constants defined in SwingConstants: LEFT, CENTER (the default), RIGHT, LEADING or TRAILING.
See Also:
JLabel.setHorizontalAlignment(int), NavBarItem.setHorizontalAlignment(int), State.setHorizontalAlignment(int)

setHorizontalTextPosition

public void setHorizontalTextPosition(int textPosition)

Sets the default horizontal text position for each of the three states.

NOTE: These changes will override changes made to the states of any item before they are added to a category.

Parameters:
textPosition - One of the following constants defined in SwingConstants: LEFT, CENTER (default), RIGHT, LEADING, or TRAILING.
See Also:
JLabel.setHorizontalTextPosition(int), NavBarItem.setHorizontalTextPosition(int), State.setHorizontalTextPosition(int)

setInsets

public void setInsets(java.awt.Insets insets)
Sets a boundary around each item.

Parameters:
insets - The insets representing the item boundary

setItemColors

public void setItemColors(java.awt.Color c)

Sets the default colors for each of the three states.

NOTE: These changes will override changes made to the states of any item before they are added to a category.

Parameters:
c - The new default Color for new NavBarItems

setItemFonts

public void setItemFonts(java.awt.Font font)

Sets the default font for each of the three states.

NOTE: These changes will override changes made to the states of any item before they are added to a category.

Parameters:
font - The new default Font for new NavBarItems

setItemSelectedState

public void setItemSelectedState(State s)
Sets the default set of attributes an item will be given when the item is selected.

Parameters:
s - The new item-selected State
See Also:
State

setMouseNotOverState

public void setMouseNotOverState(State s)
Sets the default set of attributes an item will be given when the mouse is not over it, and it is not selected.

Parameters:
s - The new mouse-not-over State
See Also:
State

setMouseOverState

public void setMouseOverState(State s)
Sets the default set of attributes an item will be given when the mouse is moved over it, and it is not selected.

Parameters:
s - The new mouse-over State
See Also:
State

setTextColor

public void setTextColor(java.awt.Color c)
Sets the foreground (text) color of the category header button.

Parameters:
c - The text color on the header button

setVerticalAlignment

public void setVerticalAlignment(int alignment)

Sets the default vertical text alignment for each of the three states.

NOTE: These changes will override changes made to the states of any item before they are added to a category.

Parameters:
alignment - One of the following constants defined in SwingConstants: TOP, CENTER (the default), or BOTTOM.
See Also:
JLabel.setVerticalAlignment(int), NavBarItem.setVerticalAlignment(int), State.setVerticalAlignment(int)

setVerticalTextPosition

public void setVerticalTextPosition(int textPosition)

Sets the default vertical text position for each of the three states.

NOTE: These changes will override changes made to the states of any item before they are added to a category.

Parameters:
textPosition - One of the following constants defined in SwingConstants: TOP, CENTER, or BOTTOM (the default).
See Also:
JLabel.setVerticalTextPosition(int), NavBarItem.setVerticalTextPosition(int), State.setVerticalTextPosition(int)


Copyright © 2004 SyGem Software. All Rights Reserved.