Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.6.0)

E13403-07

oracle.javatools.controls.nicelist
Class NiceListRenderer<T>

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 oracle.javatools.controls.nicelist.NiceListRenderer<T>
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.ListCellRenderer

public abstract class NiceListRenderer<T>
extends javax.swing.JPanel
implements javax.swing.ListCellRenderer

A custom list cell renderer that displays a multi row list item with a gradient selection highlight and several attributes:

Generally, this renderer is designed to be used in conjunction with NiceList. Clients should provide a subclass of NiceListRenderer that knows how to return the correct values for the above attributes for a given item in the list model.

This renderer is accessible. It returns the title and both descriptions as part of its accessible state. In addition, the accessible role of the renderer is a check item, allowing assistive technology to determine and interact with the state of the checkbox.

Since:
11.0
See Also:
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
 
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
NiceListRenderer()
           
 
Method Summary
 javax.accessibility.AccessibleContext getAccessibleContext()
           
protected  java.awt.Color getBackgroundColor(T listItem)
          Returns the background color for the specified item when it is not selected.
protected abstract  java.lang.String getDescription(T listItem)
          Returns the description line for the specified item.
protected  java.lang.String getHyperLinkText(T listItem)
          Returns the text of the hyperlink for the specified list item.
protected  java.awt.Image getImage(T listItem)
          Returns the image for the specified list item.
protected  javax.swing.Icon getIndicator(T listItem)
          Returns the indicator for the specified list item.
 java.awt.Component getListCellRendererComponent(javax.swing.JList list, java.lang.Object value, int index, boolean isSelected, boolean cellHasFocus)
           
protected  java.lang.String getSecondaryHyperLinkText(T listItem)
          Returns the text of the secondary hyperlink for the specified list item.
protected  java.lang.String getSecondDescription(T listItem)
          Returns the second description line for the specified item.
 java.lang.String getText()
           
protected abstract  java.lang.String getTitle(T listItem)
          Returns the title (main text) for the specified item.
protected  boolean isCheckable(T listItem)
          Returns true if a checkbox is rendered for the specified item.
protected abstract  boolean isItemSelected(T listItem)
          Returns whether the specified item is selected (checked).
 boolean isRadioButtonStyle()
          Returns true if checkboxes are rendered as radio buttons.
 void paintComponent(java.awt.Graphics g)
           
 void setGradientColor(java.awt.Color light, java.awt.Color dark)
          Sets the color to use for the selection gradient.
 void setRadioButtonStyle(boolean radioButtonStyle)
          Sets whether the checkboxes are rendered as radio buttons or checkboxes.
 void setSelectedForeground(java.awt.Color color)
          Set the foreground color for selected rows.
 void setTwoLineDescription(boolean twoLine)
          Set whether there are two description lines.
 void setUnselectedForeground(java.awt.Color color)
          Set the foreground color for non selected rows.
 
Methods inherited from class javax.swing.JPanel
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, 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, setBackground, 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
 

Constructor Detail

NiceListRenderer

public NiceListRenderer()
Method Detail

setRadioButtonStyle

public final void setRadioButtonStyle(boolean radioButtonStyle)
Sets whether the checkboxes are rendered as radio buttons or checkboxes. By default, this property is false.

Parameters:
radioButtonStyle - if true, the checkboxes are rendered as radio buttons. If false, they are rendered as regular checkboxes.

isRadioButtonStyle

public final boolean isRadioButtonStyle()
Returns true if checkboxes are rendered as radio buttons.

Returns:
true if chekcboxes are rendered as radio buttons.

setGradientColor

public final void setGradientColor(java.awt.Color light,
                                   java.awt.Color dark)
Sets the color to use for the selection gradient.

Parameters:
light - the light color to use for the gradient. Must not be null.
dark - the dark color to use for the gradient. Must not be null.

setSelectedForeground

public final void setSelectedForeground(java.awt.Color color)
Set the foreground color for selected rows.

Parameters:
color - the color to use for the foreground of selected rows. Must not be null.

setUnselectedForeground

public final void setUnselectedForeground(java.awt.Color color)
Set the foreground color for non selected rows.

Parameters:
color - the color to use for the foreground of non selected rows. Must not be null.

setTwoLineDescription

public final void setTwoLineDescription(boolean twoLine)
Set whether there are two description lines.

Parameters:
twoLine - if true, two description lines will be displayed. If false, only one will be displayed.

paintComponent

public final void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

getListCellRendererComponent

public final java.awt.Component getListCellRendererComponent(javax.swing.JList list,
                                                             java.lang.Object value,
                                                             int index,
                                                             boolean isSelected,
                                                             boolean cellHasFocus)
Specified by:
getListCellRendererComponent in interface javax.swing.ListCellRenderer

getBackgroundColor

protected java.awt.Color getBackgroundColor(T listItem)
Returns the background color for the specified item when it is not selected.

This implementation returns a color which is almost white.

Parameters:
listItem - an item in the list.
Returns:
the color to use for the item, may be null.

getText

public final java.lang.String getText()
Returns:
the title text for use in the abbot testing tool

getTitle

protected abstract java.lang.String getTitle(T listItem)
Returns the title (main text) for the specified item.

Parameters:
listItem - an item in the list.
Returns:
the text for the specified item. Must not be null, but may be the empty string.

getDescription

protected abstract java.lang.String getDescription(T listItem)
Returns the description line for the specified item.

Parameters:
listItem - an item in the list.
Returns:
the description for the specified item. Must not be null, but may be the empty string.

getSecondDescription

protected java.lang.String getSecondDescription(T listItem)
Returns the second description line for the specified item. This will only be rendered if you first call setTwoLineDescription(boolean) with an argument of true.

Parameters:
listItem - an item in the list.
Returns:
the text of the second description line for the specified list item, may be null.

isItemSelected

protected abstract boolean isItemSelected(T listItem)
Returns whether the specified item is selected (checked).

Parameters:
listItem - an item in the list.
Returns:
true if the item is selected (checked), false otherwise.

getHyperLinkText

protected java.lang.String getHyperLinkText(T listItem)
Returns the text of the hyperlink for the specified list item.

This implementation returns an empty string.

Parameters:
listItem - the list item to get a hyperlink for.
Returns:
the text for the hyperlink. If null or the empty string, no hyperlink will be displayed for the specified item.

getSecondaryHyperLinkText

protected java.lang.String getSecondaryHyperLinkText(T listItem)
Returns the text of the secondary hyperlink for the specified list item.

This implementation returns an empty String.

Parameters:
listItem - the list item to get a hyperlink for.
Returns:
the text for the hyperlink. If null or the empty string, no hyperlink will be displayed for the specified item.

getIndicator

protected javax.swing.Icon getIndicator(T listItem)
Returns the indicator for the specified list item. The indicator is an icon displayed to the right of the row.

This implementation returns null.

Parameters:
listItem - the item to get the indicator for.
Returns:
an icon for the specified list item. If null, no icon will be displayed.

getImage

protected java.awt.Image getImage(T listItem)
Returns the image for the specified list item. The image is displayed to the right of the row.

This implementation returns null.

Parameters:
listItem - the item to get the image for.
Returns:
an image for the specified list item. If null, no image will be displayed.

isCheckable

protected boolean isCheckable(T listItem)
Returns true if a checkbox is rendered for the specified item.

This implementation returns true.

Parameters:
listItem - an item.
Returns:
true if a checkbox is rendered for this item.

getAccessibleContext

public javax.accessibility.AccessibleContext getAccessibleContext()
Specified by:
getAccessibleContext in interface javax.accessibility.Accessible
Overrides:
getAccessibleContext in class javax.swing.JPanel

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.6.0)

E13403-07

Copyright © 1997, 2011, Oracle. All rights reserved.