Class JRendererCheckBox
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.AbstractButton
-
- javax.swing.JToggleButton
-
- javax.swing.JCheckBox
-
- org.jdesktop.swingx.renderer.JRendererCheckBox
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.ItemSelectable
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
,javax.swing.SwingConstants
,PainterAware
public class JRendererCheckBox extends javax.swing.JCheckBox implements PainterAware
AJCheckBox
optimized for usage in renderers and with a minimal background painter support.Note: As of revision #4223, there's a complete overhaul (aka: changed the tricksery) to fix Issue swingx-1513 (allow client code to set renderer transparent) while keeping fix Issue swingx-897 (striping/background lost when painter installed)
Note: The change of logic _did_ introduce a regression (swingx-1546) which was fixed by forcing the box's opacity to true (for regression release 1.6.5-1). Further improvements (like f.i. the option to delegate to the ui's update - to allow LAF installed painters - instead of paint) are deferred to a later normal release, more discussions needed.
- See Also:
paintComponent(Graphics)
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JCheckBox
javax.swing.JCheckBox.AccessibleJCheckBox
-
Nested classes/interfaces inherited from class javax.swing.JToggleButton
javax.swing.JToggleButton.AccessibleJToggleButton, javax.swing.JToggleButton.ToggleButtonModel
-
Nested classes/interfaces inherited from class javax.swing.AbstractButton
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
fakeTransparency
a flag to prevent ui painting from filling the background.protected Painter
painter
the swingx painter-
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
-
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
-
-
Constructor Summary
Constructors Constructor Description JRendererCheckBox()
Instantiates a JRendererCheckBox with opacity true.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
Overridden for performance reasons.protected void
firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
Overridden for performance reasons.Painter
getPainter()
void
invalidate()
Overridden for performance reasons.boolean
isContentAreaFilled()
private boolean
isNimbus()
Hack around Nimbus not respecting background colors if UIResource.boolean
isOpaque()
protected void
paintComponent(java.awt.Graphics g)
Overridden to snatch painting from super if a painter installed or Nimbus detected.protected void
paintComponentWithPainter(java.awt.Graphics2D g)
private void
paintPainter(java.awt.Graphics g)
Hack around AbstractPainter.paint bug which disposes the Graphics.void
repaint()
Overridden for performance reasons.void
repaint(long tm, int x, int y, int width, int height)
Overridden for performance reasons.void
repaint(java.awt.Rectangle r)
Overridden for performance reasons.void
revalidate()
Overridden for performance reasons.void
setPainter(Painter painter)
void
setToolTipText(java.lang.String text)
void
validate()
Overridden for performance reasons.-
Methods inherited from class javax.swing.JCheckBox
getAccessibleContext, getUIClassID, isBorderPaintedFlat, paramString, setBorderPaintedFlat, updateUI
-
Methods inherited from class javax.swing.AbstractButton
actionPropertyChanged, addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, configurePropertiesFromAction, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, removeNotify, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, 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, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, 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, 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, requestFocus, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
painter
protected Painter painter
the swingx painter
-
fakeTransparency
private boolean fakeTransparency
a flag to prevent ui painting from filling the background.
-
-
Method Detail
-
getPainter
public Painter getPainter()
- Specified by:
getPainter
in interfacePainterAware
-
setPainter
public void setPainter(Painter painter)
- Specified by:
setPainter
in interfacePainterAware
-
isOpaque
public boolean isOpaque()
Overridden to return false if painting flag is true.
- Overrides:
isOpaque
in classjavax.swing.JComponent
-
isContentAreaFilled
public boolean isContentAreaFilled()
Overridden to return false if painting flag is true.
- Overrides:
isContentAreaFilled
in classjavax.swing.AbstractButton
-
setToolTipText
public void setToolTipText(java.lang.String text)
Overridden to not automatically de/register itself from/to the ToolTipManager. As rendering component it is not considered to be active in any way, so the manager must not listen.
- Overrides:
setToolTipText
in classjavax.swing.JComponent
-
paintComponent
protected void paintComponent(java.awt.Graphics g)
Overridden to snatch painting from super if a painter installed or Nimbus detected.The overall logic currently (since 1.6.5) is to simply call super without SwingX painter. Otherwise, that is with SwingX painter:
- if opaque
- set a flag which fakes transparency, that is both
contentAreaFilled
andopaque
return false - fill background with the component's background color
- apply swingx painter
- hook into
ui.paint(...)
- reset the flag
- set a flag which fakes transparency, that is both
- else
- apply swingx painter
-
- call super
-
- Overrides:
paintComponent
in classjavax.swing.JComponent
- if opaque
-
isNimbus
private boolean isNimbus()
Hack around Nimbus not respecting background colors if UIResource. So by-pass ...- Returns:
-
paintPainter
private void paintPainter(java.awt.Graphics g)
Hack around AbstractPainter.paint bug which disposes the Graphics. So here we give it a scratch to paint on.TODO - remove again, the issue is fixed?
- Parameters:
g
- the graphics to paint on
-
paintComponentWithPainter
protected void paintComponentWithPainter(java.awt.Graphics2D g)
- Parameters:
g
-
-
invalidate
public void invalidate()
Overridden for performance reasons. See the Implementation Note for more information.- Overrides:
invalidate
in classjava.awt.Container
- Since:
- 1.5
-
validate
public void validate()
Overridden for performance reasons. See the Implementation Note for more information.- Overrides:
validate
in classjava.awt.Container
-
revalidate
public void revalidate()
Overridden for performance reasons. See the Implementation Note for more information.- Overrides:
revalidate
in classjavax.swing.JComponent
-
repaint
public void repaint(long tm, int x, int y, int width, int height)
Overridden for performance reasons. See the Implementation Note for more information.- Overrides:
repaint
in classjavax.swing.JComponent
-
repaint
public void repaint(java.awt.Rectangle r)
Overridden for performance reasons. See the Implementation Note for more information.- Overrides:
repaint
in classjavax.swing.JComponent
-
repaint
public void repaint()
Overridden for performance reasons. See the Implementation Note for more information.- Overrides:
repaint
in classjava.awt.Component
- Since:
- 1.5
-
firePropertyChange
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
Overridden for performance reasons. See the Implementation Note for more information.- Overrides:
firePropertyChange
in classjava.awt.Component
-
firePropertyChange
public void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
Overridden for performance reasons. See the Implementation Note for more information.- Overrides:
firePropertyChange
in classjavax.swing.JComponent
-
-