DESY ACOP Beans Home

com.cosylab.gui.components
Class PanelTitleBar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.cosylab.gui.components.PanelTitleBar
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class PanelTitleBar
extends javax.swing.JPanel

This is a JComponent, which is a combination of a label and a toolbar. It contains an Icon read-write property called icon, which sets the icon to be displayed in the left part of the title bar. The String read-write property title, which is the text written to the right of the icon, and a set of JButton objects displayed on the right side of the title bar or below the label.
The default color of the title bar is retrieved from the ColorHelper class and can change with different virtual machines and L&Fs. Two different colors are used: focus color for the left start of the background gradient and textHighlight color for the right part. When the PanelTitleBar is not in active state, the whole bar is painted with the background color. The changes of state can be achieved by calling the setActive() method.

Version:
$id$
Author:
Miha Kadunc
See Also:
TitledPanel, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String ACTION_STICKY
          DOCUMENT ME!
static java.lang.String ACTION_VISIBLE
          DOCUMENT ME!
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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
PanelTitleBar()
          Constructs a default empty PanelTitleBar.
PanelTitleBar(java.lang.String title)
          Constructs a PanelTitleBar with a title.
PanelTitleBar(java.lang.String title, javax.swing.Icon icon, int height)
          Constructs a PanelTitleBar with a defined height, a title and an icon.
 
Method Summary
 void addActionButton(javax.swing.Action action)
          Adds a button activating the specified action to the component.
 void addActionButton(int index, javax.swing.Action action)
          Adds a button activating the specified action to the component at the index specified.
 void addButton(javax.swing.AbstractButton button)
          Adds a button to this component.
 void addButton(int index, javax.swing.AbstractButton button)
          Adds an AbstractButton to this title bar.
 boolean containsAction(javax.swing.Action action)
          Returns true if this title button contains specified action.
 boolean containsButton(javax.swing.AbstractButton button)
          Returns true if this title button contains specified button.
 java.awt.Color getBackgroundStart()
          Returns the color used for active background.
protected  java.util.ArrayList getButtonsList()
           
 javax.swing.Icon getIcon()
          Gets the icon property.
 javax.swing.border.Border getOverBorder()
          DOCUMENT ME!
 javax.swing.border.Border getPressedBorder()
          DOCUMENT ME!
 java.lang.String getTitle()
          Gets the title property.
 int getTitleBarHeight()
          Returns the higth of panel with the title bar.
 GradientLabel getTitleLabel()
          DOCUMENT ME!
 boolean hasAction(javax.swing.Action act)
          DOCUMENT ME!
 void removeActionButton(javax.swing.Action action)
          Removes the button connected to the specified action from this title bar.
 void removeButton(javax.swing.AbstractButton button)
          Removes the specified button from this title bar.
 void setActive(boolean active)
          Sets the state of this title bar.
 void setBackground(java.awt.Color c)
          Sets the background color of inactive title bar and the right color of an active title bar.
 void setBackground(java.awt.Color backgroundStart, java.awt.Color background)
          Sets the background colors for the component.
 void setBackgroundStart(java.awt.Color c)
          Returns the color used for active background.
 void setIcon(javax.swing.Icon icon)
          Sets the icon property.
 void setOverBorder(javax.swing.border.Border overBorder)
          Sets the overBorder.
 void setPressedBorder(javax.swing.border.Border pressedBorder)
          Sets the pressedBorder.
 void setTitle(java.lang.String title)
          Sets the title property, which is displayed in the top-left area of this title bar.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACTION_STICKY

public static final java.lang.String ACTION_STICKY
DOCUMENT ME!

See Also:
Constant Field Values

ACTION_VISIBLE

public static final java.lang.String ACTION_VISIBLE
DOCUMENT ME!

See Also:
Constant Field Values
Constructor Detail

PanelTitleBar

public PanelTitleBar(java.lang.String title,
                     javax.swing.Icon icon,
                     int height)
Constructs a PanelTitleBar with a defined height, a title and an icon.

Parameters:
title - The String that labels the title bar.
icon - The Icon which will be displayed in the left.
height - Height of the title bar and size of the buttons.

PanelTitleBar

public PanelTitleBar(java.lang.String title)
Constructs a PanelTitleBar with a title. The height is set to 24 points and there is no icon shown.

Parameters:
title - The String that labels the title bar.

PanelTitleBar

public PanelTitleBar()
Constructs a default empty PanelTitleBar. The title bar is 24 points high, has no title or icon and contains no buttons.

Method Detail

getTitle

public java.lang.String getTitle()
Gets the title property.

Returns:
Returns the String that labels this title bar.

setTitle

public void setTitle(java.lang.String title)
Sets the title property, which is displayed in the top-left area of this title bar.

Parameters:
title - The text to be shown as the title.

getIcon

public javax.swing.Icon getIcon()
Gets the icon property.

Returns:
Returns the Icon that is displayed by this title bar.

setIcon

public void setIcon(javax.swing.Icon icon)
Sets the icon property. The Icon passed as the parameter to this method is displayed in the top left corner of this panel.

Parameters:
icon - the icon to be set.
See Also:
setIcon(Icon)

addButton

public void addButton(int index,
                      javax.swing.AbstractButton button)
Adds an AbstractButton to this title bar. Note that all the user has to provide is the button's icon and an associated action. All the behaviour needed for the button to fit into the title bar will be added to the button by the PanelTitleBar. The button will be resized to a square with the same size as the height of the bar. Its background color will be changed to that of the bar and the border will be removed. Some mouse and keyboard sensitivity will be added to the button.

Parameters:
index - DOCUMENT ME!
button - The button to be added to the title bar.
See Also:
removeButton(AbstractButton)

addButton

public void addButton(javax.swing.AbstractButton button)
Adds a button to this component.

Parameters:
button -
See Also:
addActionButton(int, Action)

addActionButton

public void addActionButton(int index,
                            javax.swing.Action action)
Adds a button activating the specified action to the component at the index specified.

Parameters:
index -
action -
See Also:
addButton(int, AbstractButton)

addActionButton

public void addActionButton(javax.swing.Action action)
Adds a button activating the specified action to the component.

Parameters:
action -
See Also:
addButton(int, AbstractButton)

removeButton

public void removeButton(javax.swing.AbstractButton button)
Removes the specified button from this title bar.

Parameters:
button - The button to be removed.

containsButton

public boolean containsButton(javax.swing.AbstractButton button)
Returns true if this title button contains specified button.

Parameters:
button - The button to be tested for containment
Returns:
true if button is on this title panel

removeActionButton

public void removeActionButton(javax.swing.Action action)
Removes the button connected to the specified action from this title bar.

Parameters:
action - The button to be removed.

containsAction

public boolean containsAction(javax.swing.Action action)
Returns true if this title button contains specified action.

Parameters:
action - The action to be tested for containment
Returns:
true if action is on this title panel

setActive

public void setActive(boolean active)
Sets the state of this title bar. If active parameter is true, the background will be changed to the Metal L&F's focus color, otherwise it will be changed to the window title background color.

Parameters:
active - The flag determining the state of the title bar.

getTitleLabel

public GradientLabel getTitleLabel()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getButtonsList

protected java.util.ArrayList getButtonsList()

getBackgroundStart

public java.awt.Color getBackgroundStart()
Returns the color used for active background.

Returns:
Color

setBackgroundStart

public void setBackgroundStart(java.awt.Color c)
Returns the color used for active background.

Parameters:
c - The color that should be used as the background for active PanelTitleBar

setBackground

public void setBackground(java.awt.Color backgroundStart,
                          java.awt.Color background)
Sets the background colors for the component.

Parameters:
backgroundStart - The color used for left part of the component when active
background - The color used for right part of active background and inactive background.

setBackground

public void setBackground(java.awt.Color c)
Sets the background color of inactive title bar and the right color of an active title bar.

Overrides:
setBackground in class javax.swing.JComponent
See Also:
setBackgroundStart(Color)

getOverBorder

public javax.swing.border.Border getOverBorder()
DOCUMENT ME!

Returns:
Border

getPressedBorder

public javax.swing.border.Border getPressedBorder()
DOCUMENT ME!

Returns:
Border

setOverBorder

public void setOverBorder(javax.swing.border.Border overBorder)
Sets the overBorder.

Parameters:
overBorder - The overBorder to set

setPressedBorder

public void setPressedBorder(javax.swing.border.Border pressedBorder)
Sets the pressedBorder.

Parameters:
pressedBorder - The pressedBorder to set

hasAction

public boolean hasAction(javax.swing.Action act)
DOCUMENT ME!

Parameters:
act -
Returns:

getTitleBarHeight

public int getTitleBarHeight()
Returns the higth of panel with the title bar.

Returns:
Returns the title bar height.


Copyright © 2010. All Rights Reserved.