Package com.portal.bas
Class PFieldComponentRenderer
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
com.portal.bas.PFieldComponentRenderer
- All Implemented Interfaces:
Exportable
,ImageObserver
,MenuContainer
,Serializable
,Accessible
,ListCellRenderer
,SwingConstants
,TableCellRenderer
- Direct Known Subclasses:
PLinkRenderer
,PServicesFieldRenderer
,PSubFieldComponentRenderer
public class PFieldComponentRenderer
extends JLabel
implements ListCellRenderer, TableCellRenderer, Exportable
PFieldComponentRenderer
is a generic renderer component for
PFieldComponent
objects. It abstracts out the
formatting needed to display these kinds of objects.- Version:
- 9
- Author:
- Larry Lynch-Freshner
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JLabel
JLabel.AccessibleJLabel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of the renderer based on the supplied component.Creates a new instance of the renderer based on the supplied format object.PFieldComponentRenderer
(String format) Creates a new instance of the renderer based on the supplied format string.PFieldComponentRenderer
(String format, Locale loc) Creates a new instance of the renderer based on the supplied format string and locale info. -
Method Summary
Modifier and TypeMethodDescriptionThis method is called from the PIASpreadsheet, to display the data appropriately when the table is exported.getDisplayedData
(Object value) protected Component
getFormattedLabel
(Object value, Color focusColor) Gets the formatted label for display.getListCellRendererComponent
(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) Gets a renderer for a list cell at a specified position.getTableCellRendererComponent
(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) Gets a renderer for a specific list cell.void
void
overrideCurrencySymbol
(String newSymbol) Uses a passed-in currency symbol to override the currency symbol used by the default locale.void
setCurrencyFormat
(NumberFormat newFormat) Changes the currency format.void
Changes the renderer's format object.void
setDisplayFormat
(String format) Changes the renderer's format string.void
setDisplayFormat
(String format, Locale loc) Changes the renderer's format string.void
Specifies the background color for the rows in this component.void
setRowBackground
(Color c1, Color c2) Specifies the alternating row color scheme for the component.Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
PFieldComponentRenderer
Creates a new instance of the renderer based on the supplied format string.- Parameters:
format
- the format string to use for rendering
-
PFieldComponentRenderer
Creates a new instance of the renderer based on the supplied format string and locale info.- Parameters:
format
- the format string to use for renderingloc
- the locale to format for
-
PFieldComponentRenderer
Creates a new instance of the renderer based on the supplied component.- Parameters:
parent
- the component to render
-
PFieldComponentRenderer
Creates a new instance of the renderer based on the supplied format object.- Parameters:
fmt
- the format to use for rendering
-
-
Method Details
-
setDisplayFormat
Changes the renderer's format object.- Parameters:
format
- the format to use for rendering
-
setDisplayFormat
Changes the renderer's format string.- Parameters:
format
- the format to use for rendering
-
setDisplayFormat
Changes the renderer's format string.- Parameters:
format
- the format to use for renderingloc
- the locale
-
overrideCurrencySymbol
Uses a passed-in currency symbol to override the currency symbol used by the default locale.- Parameters:
newSymbol
- aString
that contains the replacement currency symbol
-
getListCellRendererComponent
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) Gets a renderer for a list cell at a specified position. This is the core of the renderer for lists.- Specified by:
getListCellRendererComponent
in interfaceListCellRenderer
- Parameters:
list
- the list for which to format a rowvalue
- the value to formatindex
- the list position of the valueisSelected
- true if the value is selected; false otherwisecellHasFocus
- true if the cell has focus; false otherwise- Returns:
- A renderer for the specified cell.
-
getTableCellRendererComponent
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) Gets a renderer for a specific list cell. This is the core of the renderer for lists.- Specified by:
getTableCellRendererComponent
in interfaceTableCellRenderer
- Parameters:
table
- the table for which to format a cellvalue
- the value to formatisSelected
- true if the value is selected; false otherwisehasFocus
- true if the cell has focus; false otherwiserow
- the table row for the valuecolumn
- the table column of the value- Returns:
- A renderer for the specified cell.
-
setRowBackground
Specifies the background color for the rows in this component.- Parameters:
c
- the (unselected) row background color
-
setRowBackground
Specifies the alternating row color scheme for the component.- Parameters:
c1
- the (unselected) row background color for odd rowsc2
- the (unselected) row background color for even rows
-
getDisplayedData
-
getFormattedLabel
Gets the formatted label for display.- Parameters:
value
- the type of component to labelfocusColor
- the current border color; iffocusColor
is null, the label is rendered without borders- Returns:
- This renderer.
-
setCurrencyFormat
Changes the currency format.- Parameters:
newformat
- the new currency format
-
ignoreFormatingForClass
-
getDataToDisplay
This method is called from the PIASpreadsheet, to display the data appropriately when the table is exported.- Specified by:
getDataToDisplay
in interfaceExportable
- Parameters:
o
- Object- Returns:
- String
-